Change the color of badges based on the state of the sensor

I would like to be able to change the color of the badge of a sensor based on the state of the data.
So for instance if the sensor returns “bad” I would like to change the badge to an “!” (this I have done and works well) but I cannot figure out how (or even if it is possible) to make the badge red.
If the sensor then returns “good” as a state I would like to change the badge to a tick (also this I have done) but then make the badge green.