Change the attribute of a sensor through automation?

Is it possible to change the attribute of a sensor through automation? Preferably without using other sensors. Unfortunately, my attempts so far have failed.
Background: I would like to assign an icon and a state_color to climate sensors (temperature etc.) depending on the trend. But as an attribute in the same sensor.

In hacs / auotmation there is a ‘entities’ python script that can do this but…if the sensor is updated outside of the automation then this will of course overwrite

Just do it in the frontend with this:

Thank you! I already use the ‘Config Template Card’, good idea! I’m only interested in the display in the dashboard.