First off you should really only ever use a template trigger if there is no other way around it. Because this template will get rendered for EVERY state change of EVERY entity_id. So if another state changes while the sensor state of your sensor (switch.garage_door.attributes.sensor_state) is still on it will fire multiple times.
Furthermore why does your switch have an attribute called sensor state? Shouldn’t that be a sensor on his own?
But to your problem:
You could also try is_state_attr like in my multiline example.
I have had multiple instance where it was only possible to get templates to work by using multiline…in your case this would look like this:
...
value_template: >-
{%- if is_state_attr("switch.garage_door", "sensor_state", "on") -%}
true
{%- endif -%}
...