How to change the value of a sensor to hex and send it with mqtt publish?

I want to creat a automation to send the value or state of sensor which is changed to hex. how to write the payload template?
for example, my room temperature is 10.2℃, want to change the 10 to hex as 0A and 2 as 02, then add header AA and foot BB,at last,the value change to AA 0A 02 BB and published.
have try many method but failed. can someone help me? :cry: :cry: :sob: