Indeed, two gay partners can "become one flesh" although many conservative folks might find that icky.  Since the institutional church withholds its presence at gay marriages, that might be considered an "in extremis" circumstance.  In any event, it is the marriage partners themselves who bestow the sacrament.  Gender is a non-essential.