For the physical cabling, you could use an Apple Thunderbolt 3-to-2 adapter and a Thunderbolt 1/2 cable. Then you would need to set up IP-over-Thunderbolt (a.k.a. Thunderbolt Bridge) on both Macs.
Use IP over Thunderbolt to connect Mac computers - Apple Support
Note that this could let you do networked file sharing between the Macs, but it would not let you use the 27" iMac as a Target Display Mode display for the 16" MBP.
- Your iMac (Retina 5K, 27-inch, Late 2014) does not support Target Display Mode. No Retina iMac does. It was when your Mac (the first Retina 5K iMac) came out that Target Display Mode for new 27" iMacs went away.
- Your 16" M1 Max MBP is too new to use any iMac as a Target Display (even the ones that have that feature).
Use your iMac as a display with target display mode - Apple Support
There is a product called Luna Display whose USB-C version might let you reuse the 27" iMac as a second display for the 16" MBP. However, even with a Thunderbolt connection between the two Macs, this would not be as good as a real hardware connection, and I believe you would be limited to refresh rates of 30 or 45 Hz if you wanted to use the iMac's full 5K resolution,.