Thanks so much for the question submission!
You can do this if your thermostat supports using Alexa! I needed to buy a new thermostat last year, and selected a model that would support Alexa and Google.
A good way to check if yours does or not would be to contact the manufacturer, give them the model number, and see what they say.
If your thermostat is supported by Alexa, you can join the thermostat to your WiFi network, download the manufacturer’s app to control it, then find the appropriate Amazon Skill from the manufacturer so you can control it through Alexa. From there you should be able to set up a Routine that invokes the skill.
Definitely call your thermostat manufacturer and ask them some questions – they may be able to walk you through the whole process in just one phone call.