Maybe someone with an iPhone can see if this works.
I can confirm that it worked with an earlier AT&T-only phone on the pre-Cingular version of AT&T Wireless (circa 2002 version).
The phone is the Siemens S46. The unlock technique is simple.
Find somewhere without a cell signal. In my case, this is a corner of my basement, as long as the phone is in an old coffee can.
Turn off the phone.
Remove the AT&T SIM card.
Replace with a different SIM card.
Turn the phone back on.
Confirm you have no signal.
Dial 911.
Because the phone, by law, MUST make 911 calls, even without a SIM, the phone will eventually unlock and seek other GSM signals. With this phone, the Siemens S46, you can then stop the outgoing 911 call, attach the T-Mo signal, and you're in.
There you go.