Can you use iMac Retina 5K as external monitor for a MacBook Pro?
According to Apple, no. The iMac Retina 5K does not support Target Display Mode.


  Note that the iMac (Retina 5K, 27-inch, Late 2014) does not support Target Display Mode. 


You can see it here.