You cannot. The only iMacs with Target Display Mode support are the 3rd and 4th gen iMacs roughly between the years 2009 (with the 27-inch only at the beginning, later expanding the feature to the 21.5-inch when Thunderbolt was added) to 2014, excluding the 5K iMac released in late 2014.