There are zero sources of green hydrogen in the foreseeable future and railways can be electrified. Small runs that aren't electrified can use batteries. There is a zero use case for a leaky fuel that we source from creating CO2 like hydrogen. The idea of using wastefully using electrolysis to something we can deliver power directly to is ludicrous.
Edit: I can think of ONE use case, and that's maybe logging locomotives that will never be electrified.
Not in my lifetime, that's for sure. We currently supply nearly all agricultural hydrogen from oil cracking, for example. There may be a future where wastefully using hydrogen makes sense, but it's not anytime soon. An actual solution is electrifying the train lines.