Firstly, the main issue isn't money it's working hours.
But even if it were only about money, it wouldn't really work like that. The strike costs Germany about a billion in GDP. But only a fraction of that is paid for by Deutsche Bahn (the railway company). The losses mostly stem from people and goods becoming less mobile. Deutsche Bahn only loses some income from tickets which is nowhere near that much.
In the end allowing strikes in critical infrastructure isn't a good idea. Germany has a pretty good solution for that, it's about making people "Beamte"/officers. These are a special sort of civil servant that will essentially get court martialed for striking but Beamte are also practically unfirable and the constitution (and if it comes to it, the courts) ensures that they get adequate wages.
When Deutsche Bahn was an institution instead of a private company owned by the state Deutsche Bahn employees were (almost?) all Beamte. Some older ones still are (as I said, they can't be fired) and that's one of the reasons why some trains are still running. We need to get back to that or at least some rules that mimic the approach.