During the wide shot from the top of the ramparts, you can see that the dragon is much further than the rest of the Dani's guard.
Presumably it's outside of the reach of the scorpions. The show doesn't make it clear how intelligent dragons are. When they are allowed to roam, they seem to behave like cats (they come and go as they please). It's not clear if they are less intelligent, more intelligent, or as intelligent as humans. Certainly, Cersei would not know it.
For all she knew, if she killed Dani, the dragon would wait for his chance.. maybe for weeks or months. But then it would attack at night and burn down the city.
This may answer the question why Cersei had to kill Missandei. Just like in the Battle of the Bastards (when Ramsey killed Rickon), she needed to kill someone Dani cared about. This was done to draw the strongest forces into the fight.
Cersei can take on a dragon when she is prepared for it and has all the strongest defenses with her. She is not likely to fare so well if she is unprepared and the attack can come anywhere, at any moment, from a being which travels much faster than any of Cersei's own forces.
The look on Cersei's face after Missandei says "dracarys" is that of a self-satisfied smile. Her plan is working. She would much rather fight the fight where she is the strongest than have to fight against a guerrilla force with a dragon.