Open door/window sensor icon yellow color in badges - how?

A window sensor with the “Window” type icon changes the icon when a door opens. However the actual icon is not any good to depict the open window. It is not a problem as the icon becomes yellow if the sensor is presented as a button card but it is a problem if it is shown as a dashboard badge - the color does not change.
Is there a way to make badges change colors as buttons do? Thanks,

Now I have the opposite situation :slight_smile:

I am trying to add a toggle switch with a lock - “mdi:lock” - on it which would change icon to “mdi:lock-open” but instead it changes the color to yellow.

Would be nice to control the alternative icon or a color, or is there a way already?