By "close to" I guess you mean that it could have happened but not for at least 30 years after he died.
Hero of Alexandria was that "crazy smart guy." He was in Egypt, but was almost certainly also an Ancient Greek (some used to claim that he was Egyptian of Phoenician, but most say Greek. About 2/3 of those at the Musaeum of Alexandra in Egypt were Greeks after all, and most of the remaineder were Jews.)
It actually wasn't just a child's toy, it was also used to open doors (mostly in temples). The Ancients liked temples whose doors opened automatically when someone sacrificed a burnt offerings outside the doors, since the commoners think that the Gods were pleased with the offering and were opening their doors to their worshipers.
I'm not so sure the Ancient world would have had enough fuel (coal, charcoal, peat, oil, whatever) to make moving locomotives for great distances be very feasible. Their engines probably wouldn't be efficient enough to move very far or very fast (kinda like the first steam ships, which couldn't really move but had all the principles right)