It is possible to breach a door using bullets, but a normal handgun is normally underpowered.
Shotguns are suited for this task. The door isn't unlocked but partly broken so that it opens.
http://en.wikipedia.org/wiki/Door_breaching#Ballistic_breaching:
Ballistic breaching uses a projectile weapon to breach an opening. Weapons used can range from small arms to the 120mm cannon of a main battle tank with a HEAT round, which will breach most obstacles easily, though the force involved may violate the rules of engagement.[3] A less damaging ballistic breach needs to destroy either the latch and lock, or the hinges of the door, and the ideal choice for this is the shotgun. While in theory other firearms can be used, handguns are usually underpowered[4] and rifles are less effective than the shotgun and pose a far higher risk of ricochet and collateral injury.[3] Most shotgun ammunition can be used for breaching, though the risk of injury varies with type.
[1] FM 3-06-11. US Army. http://www.globalsecurity.org/military/library/policy/army/fm/3-06-11/ch3.htm. Section 3-20, Breaching
[2] Don Munson. "Action Target’s Tactical Breach Door". Tactical Response Magazine. http://www.hendonpub.com/publications/tacticalresponse/forcedentry.aspx.
[3] US Army. FM 7-8 INFANTRY RIFLE PLATOON AND SQUAD. http://www.globalsecurity.org/military/library/policy/army/fm/7-8/ch6.htm. Chapter 6, Urban Operations
[4] See Mythbusters Special 9