If it is still locked, may I presume that the contract period is still pending? If not, there may not be an issue for trading-in
Carrier Lock:- Though your iPhone’s original Carrier is not obligatory to unlock your iPhone, but you may know the process here --> How to unlock your iPhone for use with a different carrier ...
It depends on what you buy and how you pay for it.
If you buy an iPhone, iPad, Mac, or Apple Watch and pay in full, they’ll apply a credit to your original payment method up to the total purchase price. For any remaining amount, you’ll receive an Apple Store Gift Card via email.
If you buy an iPhone using Apple iPhone Payments and include a trade-in, your estimated trade-in credit will be applied directly to the purchase price of your new iPhone. Once they receive your trade-in device and confirm that the condition matches what you described, there’s nothing more you need to do. If it doesn’t match, your original payment method will be charged the difference in value. In that case, they’ll work with you to confirm that you still want to move forward with the trade-in.