Does erasing Macintosh HD then restoring from Time Machine result in the HDD being reformatted? I recently had a problem with the Macintosh HD that could not be repaired using the disk utility so I erased the disk (using disk utility) then restored from time machine (most recent backup)

Does this result in the HDD being reformatted or could any potentially bad disk areas be reused inadvertently?
Klanomath's procedures are 100% correct if it's a hard drive.

I use a tool named Scannerz to evaluate drives and it's extremely conservative. If you find bad blocks their procedures are pretty much exactly what Klanomath described, except it will be quite evident how extensive the damage is during testing. SMART technology only finds bad sectors if a write attempt to them has been made and fails. If there's a lot of damage on the drive and it's never been used because it's in free space, SMART will never know about it but Scannerz will pick it up. Zeroing the drive as described will force sector reallocation, and if the supply of spares is exhausted, the operation will fail.

If it's a manufacturing oddity that yielded a few bad blocks, the drive can be recovered by reformatting as Klanomath described. If it's extensive, you could probably partition the bad areas out but that's a risk I wouldn't take. I know some people have done it with success, but you end up with a drive with multiple volumes where one likely existed before.

As far as SSDs go, ideally their drive management software is supposed to pull bad blocks when they're encountered during a write operation. Unfortunately, an SSD, like an HD can develop an odd block here or there that just fails while it's holding data. The problem here is a dilemma, because the people responsible for writing that code must ask themselves whether or not they should just yank a block right out of the middle of an existing file and replace it with a blank, or should they leave it in place, and let the user try to recover what they can from it. This problem is rare, but it can happen.

In any case, typically there are trim and garbage collection routines that an SSD uses that will (hopefully) automatically pull the bad blocks and correct them after a failed write operation. On some SSDs, these may occur while the system is in use, on others they may occur when there's a quiet time of a few minutes.

Steer clear of any tool that tells you it's going to take a bad sector and "repair" it. There's no such thing. That's a dishonest marketing trick that has it's roots back in the 1980's when drives were using MFM and developers could actually gain access to the drive directly, and even then, it was at best only sort of possible to do it. Those days disappeared with IDE when the controller was put right on the HD.  Scannerz, for example, has an option to re-map sectors, but a warning will flash up telling you not to do it and that any information in the bad block is already basically dead, and the manual has a warning about a page and a half long, once again, basically telling you not to kid yourself.