There's quite a few gay romance games and explicit gay games out there. But I'm only aware of one good (although YMMV) SF game with both explicit sex scenes and gay options, Space Corps XXX. It seems to be trying to include every sexual orientation and almost every legal kink known to man as well as invent a few.
There are a few other good SF games on here with a gay option that I know of, but none of those have explicit set scenes. Planet Stronghold 2 and Andromeda 6 are both pretty good, just no explicit sex scenes
EDIT: IIRC Starship Inanna, another good game, gives you the option of being bisexual and it might be possible to avoid most sexual encounters with women and follow a gay path, haven't tried.