AFAIK, it isn't possible with that set up.
The only iMacs that can be used in Target Display Mode via Mini Display Port are the 27" Late 2009 and 27" Mid 2010. You can use any Mac that is capable of Mini DP out as a source to use with these iMacs as display. You can actually use non-Macs as well.
But...
The 21" Mid 2011 thru 21" Mid 2014 iMacs and the 27" Mid 2011 thru 27" Late 2013 iMacs can do Target Display Mode, but only via TB, and the source Mac must have TB1, TB2, or TB3 as well.
So, you can use your Mid 2011 iMac as a display, but only with a newer Mac that has TB. All most all Macs from 2011 to the 2020 line up can be used as the source.