I'm not familiar with the Lionel subway set wiring but apparently there's a tether between the powered unit and the trailing cars. That tether carries the dimming control so I agree you should be able to extract that information to power the sparking circuitry when the lights dim in both non-powered and the motorized unit.
Do you know how the dimming control circuit works? Does it just change a voltage on the tether or is the brightness embedded in a microprocessor digital signal?
Separately, you ought to be able to add circuitry in each car (including the motored unit) to maintain constant brightness if that's what you want.