+1 on the "NO." Not via Apple's discontinued Target Display Mode which, in its day, was quite nice if your could get it to work And that was a big "if' based on problems we've see here over the years
FACTS: The last iMac that could act as an external monitor for another Mac was discontinued on Late 2014. The last Mac that could be the video source for a supported (i.e., "old") iMac were the 2019 models.
To attempt to make it compatible a user had to purchase a 3rd party sw Bluetooth USB add-on tool and it was a glitch festival.
Not surprising given Apple decided iMacs would no longer be monitors seven years ago. There is the free option of network screen sharing:
Share the screen of another Mac - Apple Support
but even that seems ill-advised considering you would pay US$1200-1500 for an iMac that, via sharing, could only mirror the notebook's desktop and not be as responsive, and use a LOT of energy.
Frankly for US$80-100 you can today find a nice external FP monitor on sale that will have an amazing image, do extended desktop, and use FAR less energy than a computer.
Remember, when Apple instituted Target Disk Mode in Late 2009, FP external monitors were very expensive. Today, they are practically a commodity item.
Also please avoid the post-processed horse feed about Target Display Mode that appeared all over the Internet as soon as COVID hit. Articles posted by "writers" who had neither an editor nor the research skills of a vole have the world thinking that TDM is alive, well, and working with every computer ever made regardless of make and OS. It's simply not true.