Maybe you want a physical KVM in between the two sources and the monitor? I tried to get a similar setup working locally (2 monitors, a macOS source and a Debian source, supporting all four input/output combinations) and couldn't find a satisfying software solution. There were a few people using ddcutil/ddccontrol/ddctool on Linux hosts to script changes on source changes, but (a) it was difficult/impossible to get DDC to work consistently with DP and HDMI outputs with first party Nvidia drivers (b) I couldn't find anything comparable on the macOS side.
Hardware KVMs weren't much better, but if you're willing to spend the money, and have enough DP sources on both sides, they aren't too bad.
Funny how hard/expensive it is to replicate the convenience of a nice analogue KVM with a bunch of VGA/DVI/PS2 I/O, a knob, an not much else...