Yes and no. There's no video port in on your iMac, but there's various ways to use your iMac as a display for your Macbook. It has more latency than a hardware connection, but for productivity stuff, it works pretty well.
There's Luna Display, which is a hardware dongle. It's the lowest latency. It works somewhat well, but it's getting better all the time.
There's Duet Display, which is very versatile and is totally software. Latency is higher, but it can do a lot of things.
And then there's VNC, the Mac's built in screen sharing.
Note that something is running on the iMac to receive, so it's more like remote desktop than anything.
Then, I believe, there's a hardware solution where you gut your iMac and turn it into a standalone monitor.
When Apple’s new Studio Display was released last month, many people were quick to point out that panel is nearly...
9to5mac.com