Late 2011 MacBook Pro Cannot format HDD
We just has a similar issue last week at our office. Do you need to retrieve any of the data from the drive? If not:

1) Run Internet Recovery so the Macbook is not running off of the active drive (command+r at boot)
2) Open disk utility -> select drive -> partition -> 1 partition scheme, set format as appropriate, etc.
2.5) (if 2 fails) Go to Erase -> Name drive Macintosh HD and format as appropriate
3) Go to First Aid after creating partition and Repair Disk. Verify it comes back with no problems
4) Exit diskutil and run the OS installer. Will restore it back to factory shipped OS.

If you run into an issue using the Internet Recovery system due to a bad partition, use this article to create an external boot drive using IR: https://support.apple.com/en-us/HT202796