You could also detect when the battery voltage has risen to charging levels. Steady state voltage of a fully charge car battery at about 75*F is usually 12.6 Volts, and probably about 13.8 to 14.5 when charging with no major loads. This way you just need to watch the battery voltage, detect when it is around 12 volts ( car not running ) and then rises to about 13.5 volts ( running ). There will be a short time when the battery voltage drops due to cranking ( in the winter it may drop to about 10 Volts or less during cranking , but will recover fairly quickly) This way you avoid running extra wires to the alternator. This design could use a compartor and a zener to sense the change in voltage.
If you want to run wires to the alternator, there are several different alternator circuits in use, some of which will have connections that will allow you to tell exactly when the engine is running or not. These two types are often refered to as "self-exciting" alternators, or separately "exciting" alternators. The self exciting alternators only have a single main battery connection, and use this to power the the regulator. These alternators will start charging once the RPM's rise sufficiently. Separately wired alternators require an ignition "on" wire to operate, and some have a third wire, to run a voltage sensing line. With these types, the alternator produces charging voltage immediately, or as required by the battery. Using the various wires, you could determine, by the presence of charging voltage in combination with ignition wire voltage, wether or not the engine is running. This design could use "diode logic" to control a signal to the lamp.
So, all in all, what you could do is have a LM339 quad comparator, 1 section oscillating driving a transistor to flash the lamp, another section comparing the battery voltage, and when it rises, drive the lamp steady. You would use 2 diodes to isolate the oscilator and steady drive signals.
Here is the LM339 data sheet with example circuits:
https://www.electro-tech-online.com/custompdfs/2004/10/LM339-DPDF.pdf