The Civil code foresees that "two people of the same sex may contract a marriage when for at least one of them, either their personal law, or the law of the state in the territory where they have domicile or their residence, so permits it" (art. 202-1 al. 1 and 2 of the Civil code).
Also, under reservation to respect these conditions a foreigner where in their personal law homosexual marriage is forbidden, may however get married in France.
However, it is likely that this marriage will not be fully recognized abroad and not in the country of origin of the foreign spouse