Yes you can. This monitor has 3 inputs (2 HDMI, 1 DPI) which allows 3 devices to be connected at the same time. So, your XBox One can be connected to 1 HDMI, the XBox Series X can be connected to the second HDMI and you can also connect your iMac to it as a second screen; that is exactly what I am doing with this monitor. You may need to use a different adapter than me as you iMac may be different. My iMac is a 21.5" mid-2011 model and has a Thunderbolt 1 output; I connected a mini DisplayPort to DisplayPport cable to the DPI input of the monitor; I recommended the right cable on this post.
StarTech.com - 6' Mini DisplayPort to DisplayPort M/M Adapter Cable - Black
(98)