First hydrogen locomotive started working in Poland.
There are trains available that will run on overhead lines where available, and diesel when they’re not. There’s also passenger trains that have batteries as well.
It’s doable, especially considering how efficient trains are.
It’s kinda the default actually. Locomotives might lack pantographs if they never see electrified track but diesel locomotives aren’t direct drive but diesel-electric. I’m not that deep into the topic but from what I’ve heard a mechanical transmission would be a nightmare.
Modern trains are almost exclusively electric final drive, off the top of my head I can’t think of any exceptions. There are so many different voltages of overhead pantographs and drive motors though, there is almost always some type of converter needed to provide the right voltage to the drive motors.