This happened but sounds pretty loony toons.
There is a book:
The Mitchell Railroad Raiders by John A. Wilson (Kindle edition in my case, $3.27.)
Dates to the US Civil War. Things were quiet in Mid Tennessee but trains were bringing supplies to MG Bragg. So a plan was hatched to send 24 union soldiers in plain clothes to Marietta or Big Shanty in Georgia (later the site of battles in Sherman’s Atlanta campaign) to steal a locomotive, head north, destroying rails, burning bridges etc.
Sounds far fetched but would have worked. the heroes got to where the train stops so passengers could have a meal at the station (depot.) They stole the train after unhitching all the wagons.
Unfortunately they had been delayed by rain—no sealed roads! The day they steal the train there are numerous trains coming the other way. They get caught.
Eight are hanged as spies. The rest plan a desperate breakout schedule that actually works. Two of the escapees decide to head south on the grounds the rebs would be searching to the north. Harrowing tale of heading south, eating raw corn right off the cob, eating raw pumpkin, sweet potato etc. They find a boat and paddle it down south to the Gulf and find the Union blockading squadron. Along the way they sort of white water raft it, in a wooden boat, at night, twice!
Worth getting the book, only $3.27.
But can read about it here:
https://en.wikipedia.org/wiki/Great_Locomotive_ChaseBuster Keaton made a film “The General” which must have been based on the episode:
In it there is a scene where they tie a rope to a telegraph pole and the train pulls that pole out of the ground. That is in the book.