Purchase interlocking roof flashing and counterflashing that match the color and theme of your stucco. The counterflashing will mount to the roof flashing, not to the stucco, so you need to have interlocking flashing that will install seamlessly.
Unhook the existing counterflashing from the roof flashing on the wall where the eaves of the house (the underside of the roof) meets the walls. Cut the stucco away from the existing roof flashing to reveal it. Use the utility knife to score the stucco, and use the handle of your trowel to crack away and remove the existing stucco.
Remove the old flashing. Install new flashing in its place. Mount it with silicone caulking and let it dry according to the manufacturer’s recommendations, usually between 24 and 72 hours. Apply a new layer of stucco over the flashing, using the trowel, leaving the mounting brackets for the counterflashing visible. Allow the stucco to dry, then hook/mount the counterflashing on the mounts.