Colors for component icon

I’m developing a sensor platform. There is a function defined for sensors to get the icon, but as far as I could find, there is no way to change the color of the icon.

I could find some examples to change it using yaml like this:

However, I want a python way to integrate it straight in the platform code. Could this be a feature request?