Cannot format SSD in optical bay
Have just faced a similar problem with MacBook Pro (17-inch, Early 2011) and SSD installed into the Optibay. Operating system: macOS 10.12.3 (16D32).

«Disk Utility» got stuck on the «Waiting for partitions to activate» phase of the erasing process.

The solution, which worked for me, was to put the SSD into the main bay and the HDD into the Optibay.