PSA: Many 4K Dell monitors (like my Dell UltraSharp U3219Q ) have a built-in KVM switch and they support full DDC commands for switching the input as well (over HDMI, DP and USBC). I can control them from Mac and Linux with hot keys that trigger the appropriate ddc commands.

record scratch

Whoah. How do I obtain these ddc commands on macOS?

I use MonitorControl as mentioned but if you want something with a CLI then https://github.com/kfix/ddcctl works