I'll assume people panic and try to get out (otherwise this will probably work a lot more easily).
Probably the first action you'd have to take is reduce the effects of panic, which would cause people to attempt to flee en masse and cause all kinds of havoc, including problems related to quarantine.
The Lie
So you lie, but in a convenient way, so as to reduce people's certainty that fleeing is the optimal option. You broadcast that the outbreak has been identified, teams are working on a permanent cure and that people should attempt to return to their homes if they are within the city or stay at work or wherever they are if they live outside it. Claim that teams have already been dispatched to provide medical treatment, examinations for infection and temporary vaccination. You must not present this as an attack - it must look like this has been going on for a while and that people have already figured it out.
In the case of NYC, which is what I'll assume we're placing under quarantine, as an example, there is a so-called "syndromic
surveillance"[13] system they've implemented to monitor
disease outbreaks - this plan includes vaccine distribution centers as
well - thus, in the case of NYC, it's very easy to get people under
control until military lockdown.
Many thanks to KaguraRap for this info.
Also, updates should also be broadcast, even if they're fake. This is to give the impression work is getting done and the plan is working and already under way.
This of course won't influence everyone and it doesn't prevent accidents and problems overall - random zombie attacks will happen, people will go insane etc. but it will reduce the amount of people that will flee until you can lock the city down. The idea is to present the danger as smaller than it is - you confuse them enough to pause.
All means should be used - police helicopters, radio, tv, everything.
The lock-down
You'd have to immediately dispatch police and military nearby to close off all roads leaving the city (obviously). While unlikely to happen, people might still attempt to leave using the sea, if the city has access to it, so you should dispatch coast guard to prevent this.
You also make sure there's enough personnel wearing medical clothes or quarantine suits - chances are you'll need them anyway to make sure that those who are maintaining the lock-down aren't getting infected in the process.
A few policemen and military units should scan the perimeter and prepare to set it on fire, if necessary. This is assuming that around the city, there's rural or suburban areas, so you're not going to burn people's homes.
All these people should share the illusion that this is already taken care of and it's just a matter of time until it's resolved.
The lie must keep being broadcast all the time - people might have missed it the first time and others might get convinced more easily when faced with the difficulty of leaving. They should be told that the lock-down is a precaution against infected people leaving and zombies escaping.
Break-in
Eventually you'll have to send troops in to separate people from zombies and clean up. They'd have to look calm and in-control as much as possible and should enter from prominent city entrances (large, main streets). This gives people somewhere to turn to and go to. As soon as possible, units should scour the city for survivors and zombies, sending anyone who isn't a zombie yet to testing, explaining the routine procedure and promising vaccination.
People should be given placebo injections as part of testing and those who are infected should be taken to "monitoring" sections. Those not infected should be commandeered to keep things in order.
Keep people occupied and focused away from fleeing until it's too late.
Quarantine
Once enough troops are in, people are divided enough and exits are blocked, you should have good enough quarantine that, if there's a huge second outbreak, you can just order everyone to stay put while you burn the city down. Start from the perimeter.
Of course, the question is, do we have the time and people to make all of this happen?
For the following numbers and calculations, remember I am making huge arbitrary assumptions and have no idea about epidemiology, disease spread and related topics. Without knowledge of how fast people get infected, how long it takes to turn into a zombie, how long for symptoms to appear etc. there is no way to compute how many people are going to be zombies and how much time people had to figure out what was happening.
First of all, how virulent is this disease? I'm going to assume 0.02% have turned into zombies out of 50% infected at the time actions are taken to contain the outbreak. Assuming this is New York City, that means we have about 20 thousand zombies, 5 million infected and about 5 million not infected (I'm assuming the City + people who are there for shopping, traveling, tourism, business and people passing through = 10 million). I'm assuming about 20e3 zombies because that way, across the area of the City, which is 1,214 km^2[8], we get about 16.5 zombies per square kilometer ( 16.44 z/km^2 ). This means, factoring in the population density which is 10,725.4/km^2[8], we get a zombie to civilian ratio of 1.54e-3, which means 1 zombie per 650 people (this ratio, if we take Dunbar's Number into account - which says we can maintain 100-150 relationships as humans - and this article, which seems kind of terrible but references a study that claims the average american knows about 600 people, indicates that by this point, about 1/3 of the population will have heard something and may suspect something is going horribly wrong).
I'm using this amount because I assume, after having this many incidents of zombies, many of which will be taken to hospitals or attack people, over a period of a few days, it will be enough for alarms to go off (think of it as a disease - you're a doctor getting tons of incidents with the same horrible symptoms and the patients becoming murderously rabid after you think they're dead - it would look like ebola and rabies on steroids!). In other words, I'm assuming there is an attempt to quarantine the city after there are enough similar incidents around the city that pretty much everyone will have heard something and hospitals can consider it an epidemic or attack of some sort.
The US has a density of 4.4 military personnel per 1000 capita and a density of 248 police personnel per 100000 capita. Converting the ratios so that we can add them, we get 2.48 police and 4.4 military per 1000 capita, a total of 6.88 people per 1000 we can have contain the city. For New York, this would mean about 69 thousand people, but we can use the NYPD's actual numbers[11] which state that there's 34.5e3 uniformed in service, which brings the total up to 78.5e3 uniformed personnel. Add to this about 942 fire departments[4] and about 34e3 firefighters, 2/3rds of which are volunteers. Thus we have a total of about 112.5e3 personnel that can help lock down and quarantine the city.
Going by this article it seems we need 60-200 military troops per civilians to occupy the city and lock it down. With our numbers, we have 127 soldiers and police per civilian, so we should be good, considering these are infected people, disorganized and not likely to fight back.
Going by the automobiles per capita for the US which is 800:1000 approximately[12, we can assume we have about 8 million cars in the city. Assuming most people will want to take their families with them before fleeing and that some will have relatives and loved ones in hospitals or will be tending to them (or waiting for help), lets assume a third of the population gets in their cars and leaves. That gives us about 2.5 million cars leaving. I expected the police to have, say, about 1 patrol vehicle per 16 police officers since precincts reuse vehicles (are they all called officers? I mean personnel), which would give us 155 police vehicles, which is not much, but going by actual NYPD numbers[11], it seems they have 8839 cars, 11 boats, 8 helicopters, 60 horses (lol) and 34 dogs, which is a lot. We have to assume the military brings in their own vehicles, including tanks, but I can't make an estimate on those (it would depend on what kind of corps have camps nearby, the speed of these vehicles on a highway, how many can be deployed from nearby etc.).
Can these police cars form a blockade across all entrances? Lets see. Going by this map:

we can see that the highways leaving NY are 95, 87, 1 and 278. I counted 12 entrances through highway, to the city, which is how most people will want to leave. That gives us almost 736 police vehicles per highway - too many. We can also count on the military again or call in the fire department to plant their 950-1900 fire engines across the highways, using hoses to prevent rioting. This way, we can have 950/12 = ~80 fire engines across the highways if we're fast and send all the police cars to block smaller exits and maintain some control until the military lock-down.
Police should also shut down and block all subways early, as KaguraRap reminds. See the comments for more.
So far, assuming the threat is recognized in reasonable time, we should have enough people, vehicles and time to lock down the city. You can't really get a perfect containment within a few hours, but I think that there's going to be enough time and quarantine is possible. To get those that escape the city, you call all the surrounding police stations and tell them to keep watch of the road, block all cars from passing through, especially those coming from NYC.
oh also, I think I earned that zombie tag, so I made it :P