I had an AT&T one that I had unlocked from a 3rd party. Apple replaced it with another that was unlocked. I use mine on Aio network, so having it unlocked was a must.
The status of a replacement phone from Apple will be exactly what you have today. If it is locked to T-Mobile then so will the new one, if it is unlocked then the new one will also be unlocked.