Sure, lots of people have done it, including me. ( It’s actually the example I used in the changing modes FAQ.)
You can use rule machine if you like, but you don’t need to, you can also just do it with modes and routines or with Smart Lighting automations.
See the following for detailed discussion: