It's interesting as a thought, but I don't think it's likely to be large-scale practical.
Suppose you wanted to run a normal electric train up a mountain. It would certainly take a decent amount of power but not so much that it would be a big challenge for a city-scale power grid. So far you're not yet talking the scale of power where storing it would really be interesting to a grid.
One option to store more power would be to make the train much, much heavier. Sounds simple enough -- fill all of the cars with concrete and now hauling it up the mountain will store a lot more power. However now the rails and the trains themselves will need to be far sturdier than a normal railway, and will wear out quickly.
The other option will be to simply scale up -- start the day with a hundred trains in a rail yard at the bottom of the mountain and over the course of a day move them all to a rail yard at the top. Now you have successfully stored a decent amount of juice.
But hold on a minute... you've now built two large rail yards, meaning you'll need a lot of relatively flat real estate at both altitudes. How about instead you just dig a hole on each side, called it a reservoir, and put a pipe between the two? Certainly it must be a lot easier to store and move mass in the form of water than it is in the form of trains!
That is why I don't see much potential in rail-based storage: if you have the geography to build one at-scale, probably you could build pumped hydro there cheaper. Even if you were in a water-scarce area where you would need to enclose both reservoirs to avoid evaporation loss it still sounds simpler to me than building and maintaining a hundred heavy trains would be. Also, routing a pipe between two reservoirs is a lot more flexible than building a railway.