Yes, you can do that. The catch is you had to sign a two year contract to get the phone.
It's not unlocked technically, but you are free to do whatever you'd like with it. You signed a two year agreement. You can activate it wherever you'd like, but you are still stuck paying the ATT monthly fee. (one would ask why buy the phone, sign the two year deal, and sell the phone you have to use)
Again, hence why people are able to sell their iPhone before the two year contract is over. You promise to have a contract for however much money per month to ATT. You can even go and purchase a prepaid phone, swap sim cards, and have it sit on a lower price plan without the data and sell the iPhone.
If you don't want an iPhone, you can buy one, sell it, and go back to using your original phone. I promise. It can be done. Ask anybody who has purchased an iPhone with a friend, parent, siblings' upgrade, and given it to another ATT customer. I promise you can buy an iPhone and do WHATEVER the hell you want with it, but remember, you promised to keep the line active for 2 years with ATT.