A video mixer a-la Blackmagic ATEM Mini will do this. Maybe there are cheaper options if it's just being used for input switching.
A video mixer acts as the source and sink for the output and the inputs respectively, where a HDMI switch will just physically disconnect and connect the output port to a different input port, meaning the HDID negotiation has to be re-done every time.