TL;DR
The temporary train GUI already does dynamic path finding to the cursor, add a tooltip with the pathcost.What ?
Add a new debug option ie show-rail-path-cost when activated and the player holds down ctrl (to setup a temporary station) whilst in the locomotive gui the game shows a tooltip with the path cost of the path that is rendered in the window.e.g.