Yes, of course! I'm surprised anyone wouldn't.
I will note that I am in a warm country, so we much more rarely have the heat on. But if I'm out of the house for 8 hours, I'll definitely turn off the AC. It might take time to get the house cold again, but c'mon, no way we'd pay for a day's worth of electricity for no reason.
I wonder how much this changes if it's heating vs cooling, and based on how much you have to heat/cool a place.