Parrotfish has an ability to spontaneously change its gender from female to male.

Parrotfishes are a group of fishes that traditionally has been considered a family (Scaridae), but now often are considered a subfamily (Scarinae) of the wrasses.They are basically found in relatively shallow tropical and subtropical oceans throughout the world, but with the largest species richness in the Indo-Pacific. These approximately of 90 species are found in coral reefs, rocky coasts and seagrass beds and play a significant role in bioerosion.
Change In Gender : The development of parrotfish is complex and accompanied by a series of changes in color termed polychromatism. Almost all species are sequential hermaphrodites, starting as females (known as the initial phase) and then changing to males (the terminal phase).
A few species, for example the Mediterranean parrotfish are secondary gonochorist, meaning that some females do not change s*x and the ones that do, change from female to male while still immature (i.e., reproductively functioning females do not change to males).

Image Source : Wikipedia
Text Source : Wikipedia