Some drugs will induce hypermelanosis accumulation of melanin as a non-specific post-inflammatory change in predisposed individuals.
This is often worsened by sun exposure.
Some drugs induce pigmentation directly by accumulating and/or reacting with other substances in the skin.
https://www.wikihealthnews.com/