Yes! When skin is damaged or irritated, the brain triggers the enzyme that increases the production of melanin as a protective response. If during this time, skin continues to be exposed and damaged by UV rays, excessive melanin pigment will also continue to accumulate under the skin.
Always take care and protect skin especially when there is acne or scarring. Use sunscreen consistently to protect skin from UV rays and prevent existing dark spots from getting even darker.