(binary) sensor icon colour based on state

Hello,

I am busy for hours now. I have a simple binary sensor that change state when using in lovelace
(state_colour: true).

But now I wanted to add a template sensor (normal or binary) to change the name, the name works but then the colour is not changing… I have tried a lot but here is “some” of my code:

tried this below

sensors:
binary_sensor:

  - platform: template
    sensors:
      waterrelais4x_regenton_vlotter_template:
          friendly_name: Regenton Vlotter
          value_template: >
            {% if is_state('binary_sensor.waterrelais4x_regenton_vlotter', 'on') %}
              Leeg
            {% else %}
              Vol
            {% endif %}

And this included does nothing:

          icon: >
            rgb_color: "if (state === 'on') return [251, 210, 41]; else return [54, 95, 140];"

What am I missing/overlooking?