There are two native(ie Apple) ways of doing this, unfortunately your 2015 iMac falls outside of both requirements.
You can use something called Target Disc Mode on iMacs built between 2011 and late 2014:
Security verification page to protect against malicious bots.
support.apple.com
iMacs and iMac Pros later than 2019 can be used using Airplay:
Turn your iMac into a display for your MacBook or PCWant to use your iMac's awesome screen as a monitor for your MacBook or Mac desktop? If you're using a newer iMac, it's easy to use AirPlay to mirror or extend another computer's screen...
www.wikihow.com
You could use something called Luna Display or Duet Display, but you'll have to pay for it:
This in-depth guide covers how to use iMac as monitor with Apple's target display mode, with third-party software, and more.
9to5mac.com