This is great, would love to see a similar way to do it in Android.
I don't know of any way to control the setting automatically (sometimes there are special-permission non-standard/undocumented intents for settings though), but as a maybe-close-enough you can turn on grayscale color correction (in accessibility -> color & motion, in my phone) and add a quick-settings tile to toggle it.
Samsung routines can do this.
There's likely a way to do with via Tasker/MacroDroid but you'll likely need to use Shizuku (or possibly root) to change these system settings.