You can convert a physical SIM to eSIM pretty easily once you have the new phone, and it doesn't matter where you purchased it.
The
Apple Support- Transfer SIM support page provides guidance on doing it during setup or after setup. I've used it to transfer the line from a physical SIM in my mother's iPhone 11 to her iPhone 12 eSIM when she upgraded. It was much nicer than dealing with T-Mobile support.
And, to note, you don't have to be transferring it to a "new" phone. You can follow the procedure to transfer to any XS or newer on 13.1 or higher that is either unlocked or locked to the carrier issuing the SIM, in this case, T-Mobile.