Cut out the damaged section of duct using either a saw or a pair of snips. If using snips, drill a hole through the duct first to insert the snips before cutting through the duct material. If you're removing an entire piece, unscrew it from the main duct at the seams and pull it out.
Measure the dimensions of the duct you removed with a tape measure. Your replacement piece needs to be about an inch longer and a centimeter wider so it fits over the pre-existing duct.
Slide on the replacement duct piece so it overlaps both sides of the old section and drill in screws to hold it in place. If the old piece was braced, run the new piece through the old brace as well, to support its weight. Apply mastic all the way around the seam and the screws with a paintbrush and let it dry.
Wrap metal tape around the duct seam and mastic to further seal the duct and hold it in place. Avoid duct tape. Despite its name, it doesn't work well with ducts and falls off quickly.
Turn on your HVAC system and inspect the new duct for leaks as air flows through it.