You've limited the information we need to effectively answer. What OS in on the 2015 MacBook Pro running?
"Old" does not narrow down the iMac model enough to even begin to recommend how to connect. Chances are that, if running 10.4, it is far older than the range of iMac capable as being external monitors under Target Display Mode. The OLDEST iMac that can be an external monitor shipped with macOS 10.6.1.
Supported models and OS versions here:
VIDEO SOURCE COMPUTER (the one sending the video signal to an external monitor):
- A 2019 or older Intel Mac running macOS 10.15 Catalina or older.
- Apple Silicon Macs are not supported
- mac OS11 Big Sur is not supported.
TARGET COMPUTER (the one to be an external monitor):
- An iMac 27-inch (Late 2009 and Mid 2010)
- any iMac from Mid 2011 to Mid 2014.
- The target computer must run no higher macOS than OS 10.13.X High Sierra.