You can definately use variables, at least in embedded SVG's. This one is an embedded animated windrose SVG that I once used in a button_card. The bearing and the colors are variables taken from an entity and from a theme:
image: >
[[[
var bearing = states['weather.home'].attributes.wind_bearing;
return `
<svg width="60%" height="60%" viewBox="0 0 1952 1952" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g id="Layer1">
<path id="Circle" fill="var(--color-gold)" d="M975.913,0c538.62,0 975.912,437.292 975.912,975.913c0,538.62 -437.292,975.912 -975.913,975.912c-538.62,0 -975.912,-437.292 -975.912,-975.913c0,-538.62 437.292,-975.912 975.913,-975.912Zm-0,208.546c423.52,-0 767.366,343.846 767.366,767.367c0,423.52 -343.846,767.366 -767.367,767.366c-423.52,0 -767.366,-343.846 -767.366,-767.367c-0,-423.52 343.846,-767.366 767.367,-767.366Z"/>
<path id="Direction" fill="var(--color-gold)" transform="rotate(` + bearing + ` 976 976)" d="M975.915,1560.9l332.229,-1169.98l-339.429,122.592l-325.034,-122.592l332.234,1169.98Z"/>
<animateTransform additive="sum" attributeName="transform" calcMode="spline" dur="2s" keySplines=".42, 0, .58, 1; .42, 0, .58, 1" repeatCount="indefinite" type="rotate" values="0 976 976; 5 976 976; 0 976 976" />
</g>
</svg>
`;
]]]