The best option I've found is to hook both computers up to a USB-only KVM, and plug them in via separate video cables to the monitor. Then set up the computers to tell the monitor to change inputs (via DDC commands, which most but not all monitors support) when you change devices on the KVM
There's software to help do this automatically (https://github.com/haimgel/display-switch)