I have played for over 150 hours and not seen a dragon attach within the city limits. Outside the cities, yes, but not in the city world space. I suspect if one does attack within the closed cities it would be a scripted one. Just a guess on my part. however quite a few people seem to have met up with dragons within the cities. Maybe I just don't spend enough time within the cities.
I've fought one in Solitude after exiting the Blue Palace and I also encountered one in Windhelm as I was just walking to the palace to visit Ulfric. It was certainly an experience shooting the dragon down from a wall with my Epic Daedric Bow and the townspeople gathering in awe as I absorbed its soul.
It did attack in Whiterun, Amren got killed, He was a friend, so i took his family sword and hung it above the door in Breezehome in his honor.
It happend in Riften and Solitude too, but as far as i know, no one got killed.
It happend alot more often in smaller towns or villages, never happend in the College, even though i,ve been there like 100 times or more.
After 200 hours, I'm happy to report that I actually fought a Dragon inside a city! Whiterun, after fastravelling there after some dungeon crawling. It was at night, so it was really cool.
Killed the poor beast right near Breezehome on the left-hand side (if you're facing the door). So after taking a well-deserved nap upstairs, I came out in the morning to find Them Bones still in situ Flippin Sweet!