Keep dual screen active with MBP and iMac, after hibernation/sleep
You are probably best served by this app here:

https://github.com/duanefields/VirtualKVM

Download here: https://github.com/duanefields/VirtualKVM/releases

Basically "Automatically toggles Bluetooth and Target Display Mode when you connect a Macbook to your iMac via Thunderbolt."