You can have 2 automation, one which enable grayscale when certain apps are open and one that disable it when the apps are closed. It’s under shortcuts > automation > app > is closed.
I put this in a different comment but you can also have a single automation that toggles the setting for those apps on open and close. This way you have a single list of apps to maintain.