If you are considering a new Mac then no yyje 2014 iMac cannot be used as an external display. Target Display Mode is quite dead however please read Target Display Mode and pay close attention to what might work.
"To use any of these iMac models as an external display:
- The iMac used as a display must have macOS High Sierra or earlier installed.
- The other Mac that you're connecting it to must have been introduced in 2019 or earlier and have macOS Catalina or earlier installed.
- The cable connecting the two Mac computers must be a Thunderbolt or Thunderbolt 2 cable."
Your best bet though is to buy an external display and begin using that. TDM is expensive to setup (expensive cabling), not highly reliable and Apple never intentionally added it as a feature. That it worked at all for users was really a fluke. An external display should be dead reliable and easy to setup which TDM does not satisfy.