Change MQTT sensor based on value

Just learning the ins and outs of HA … and have a garage monitor sending a MQTT message on the state of the garage doors – payload is either Closed or Open. This is working fine, I see the state of the sensor and have it displayed on the dashboard.

I would like to change the associated icon to mdi:garage-open when the payload is Open. Is this doable or possible to set associated entity?

I attempted adding icon-template to the sensor definition in YAML, but this generates an error. So I assume it is not supported - correct.

To be honest, I get lost/confused as to just where and how to define the YAML. So please be explicit in any YAML examples

Thanks in advance

Please post the sensor’s configuration.