Hydrogen
can be produced electrically from water. A positively stupendous amount of electrolysis equipment will need to be built out, but there will be demand for as much as can be produced. Burning hydrogen produces mainly water. Burned in an engine, it also produces nitrous oxides, so probably some ammonia would be dissolved in to scavenge that.
Liquid hydrogen takes up a lot more room than kerosene. The insulated liquid-hydrogen tank is quite a lot bigger than the kerosene tank -- maybe it is a whole other car -- but so what? Room on a train is cheap. What matters is weight. The tank is light, and the weight of LH2 needed to go the same distance is much less. The difference is weight that doesn't itself need to be transported.
Furthermore, the LH2 can be produced and banked on-site at the railyard, and during peak-production hours, so cheaply.
So, a win all around. Not as big a win as LH2-powered aircraft, but better, and much easier to retrofit.