Dynamically update unit_of_measurement

Is there a way to dynamically change the unit_of measurement of a mqtt sensor?. I have a sensor which sends temperature reading (using MQTT) either in Celsius or Fahrenheit (The measurement unit can be changed as required in the sensor). Is it possible for me to send both the measurement and the unit to HA ?.

Thank you.

Do you really need to dynamically change it? Do you switch between F and C often?

If you just need to define the unit of measurement once put “unit_of_measurement: F”. Below your sensor. Note that you need a degree symbol before the F or C. ( I’m on my phone and can’t input one)