If I understand this correctly, the $800 trade-in rebate is credited to your account in the form of a $27 (approximate) credit every month for 30 months.
If you finance the phone, then they subtract that from your monthly payment. If you pay upfront for the phone, you still get the rebate spread over 30 months.
If I understand it correctly, I think you should be able to unlock the phone once you’ve completed your payments (whether paying in full up front, after 30 months, or any point in between if you pay more than the minimum).
If AT&T still owes you rebate money, I don’t think that will be a problem. My understanding of their terms and conditions is that you need to pay off your installment agreement. It says nothing about AT&T’s obligation to pay you your rebate.
And this makes perfect sense. The whole reason for locking is that they don’t want you to unlock a discounted phone and then switch service providers before they’ve received their profit from the deal. If you would pay off the phone early and leave them before receiving the full rebate, that benefits them, not you, so I don’t think they would object.
I think you should definitely call their customer service department and ask these specific questions.
Additionally, customer service reps are sometimes able to bend the rules. For instance, if you know you’re going to be going on a trip and you’ve been using AT&T for a long time, they may be willing to let you unlock it early, assuming that you’re not likely to cancel your service afterward.