Let's say a movable-part hard drive has a few damaged sectors somewhere. Is there a way to mark these, and a good margin neighbouring sectors, as unusable or map them to a separate partition called "broken", so that you can semi-safely use the rest of hard drive, of course at a risk, but with a smaller chance of letting the drive head going near the broken sectors?
I know this is a bad idea in principle, but some times you have old hardware with no important data that you want to keep running for fun and experiments without spending money to fix minor issues.
How can I do this using UNIX or macOS?