yes, you could create a script for this on a Gen 3 or 2 device.
Could you please provide more information on why this is needed and what you are planning to switch on, it may be that there is a simpler way to solve this problem.
Also, please specify the generation or typ of your Shelly.