Your iMac does not support Target Display Mode so you cannot directly use it as a display. You can, however, use it as a display for your 2015 MBP using e.g.
Avatron Air Display or
Duet Air. These are software solutions that must be installed on both Macs and cause additional load on your MBP's CPU. You may also experience lags. Another solution which is both hardware and software is
Luna Display which is what I personally am using.