Firstly you need to know that the bad sector cannot be repaired. The formatting process does not repair the bad sector. But yes formatting process identifies the bad sector and prevents any data from being written on it.