Passing variables to a button to pass to a script that accepts a variable

Most core dashboard cards do not support templates. https://www.home-assistant.io/dashboards/actions/#limitations

There are third party resources that add this functionality. See 📝 100% Templatable Lovelace Configurations