Alright, during which dynasty? The more modern you go the more plausible this gets.
Heron of Alexandria developed an aeolipole in the 1st century, which was fundamentally a steam powered device to make a turbine move with no practical use. However, it goes to show that Roman-era Egypt understood the concept of steam being converted into mechanical force. To make this closeish to OTL, we can start this idea off by placing the development of the aeolipile into Ptolemaic Egypt, the last period of “ancient Egypt.”
According to Wiki, the keys to developing the steam engine proper were the scientific breakthroughs of discovering the concept of vacuum and how to produce one. Now, OTL this didn’t happen until the 17th Century, but the experiment that first made the concept of a vacuum practical seems feasible in the ancient era.
In 1630, Italian physicist Giovanni Baliani built a giant siphon that failed to work; when he wrote to Galileo asking why, it was suggested that it was nature’s abhorrence of vacuum that prevented the water from flowing. This interested another scientist, Gasparo Berti, who proceeded to unintentionally create a barometer by creating a partial vacuum in a tube and basin of water. It was a third Italian, Evangelista Torricelli, who theorized it was the weight of the atmosphere holding the water in the tube and not the vacuum abhorrence, which led to his intentional development of the barometer.
So the first step is replicating the series of events that led to the invention of the barometer in Ptolemaic Egypt. One issue is that air was considered to be weightless and massless, which needs to be questioned by someone. OTL this was proven when Torricelli had a friend run his barometer up a mountain, where the atmospheric displacement was noticeably less.
I have an idea on how to accomplish this, though: much of Heron’s OTL work was intended for automata, devices running on water in places like religious institutions meant to shock and awe. Basically, have someone develop a gigantic siphon as part of an automaton. It fails, and the Alexandrian School investigates the anomaly, leading to a similar vacuum theory and barometer development. Taking one up a mountain might be hard to pull off, though; maybe someone takes it to Greece to show it off?
The next step is developing the vacuum pump, a direct development on the suction pumps well-known in the ancient world. This is where Wiki fails: does this require metallurgical advances beyond those of Ptolemaic Egypt? Assuming it doesn’t, some philosopher-physicist could probably develop something like Goelicke’s pump (of the Magdeburg hemispheres experiment fame) and experiment with removing air from an airtight cylinder or something similar.
Finally, we get to developing something like the Newcomen engine (the first basic steam engine). It requires an advanced familiarity with valves and engineering, which is why I’d suggest again that such a feat would likely come about in this time and place during the development of a complex automaton.
As a side note, you could use a political PoD to get the scientific development to kick off; maybe something averting the decline of the Ptolemies that pulled them into the Roman sphere. If the nation stayed politically powerful, you could see the sort of monumental temples that might use the giant siphons and complex automata I mentioned.
This is all a massive oversimplification and requires a ridiculous amount of contrived coincidences; it’s a “most optimistic scenario possible” for such a development and is missing quite a few steps.
Anyway, the utility of the steam engine in my scenario would first be for the automata and then move into mine pumping when someone inevitably sees the potential. It might not change much on its own—I doubt this development would spark an ancient Industrial Revolution, especially coming out of a development meant for fancy temples—but it could improve mining efficiency and improve Egypt’s financial situation to OTL.
TL;DR: use a bunch of over-the-top coincidences to precisely mirror OTL’s development of the steam engine; it’s the best I can do only using Wiki