If you get them before they have sexed( smaller juveniles) ,one will dominate and become a female,as I understand it. I've not heard of exceptions but suppose they may be out there. If they are both sexually mature , they may both be females and can't change from female to male ;only from male(xy) to female(xx). The male can shed the y chromosome and double up the x;the female has no way of acquiring a y.
In the wild a pair will usually tolerate a 3rd fish ( a male) on the fringe of their territory. If one of the pair dies that fringe male fish pairs of as a male with the female if she is the survivor ,or; if the male form the pair is the survivor , it will become a female and the fringe male will pair with it.