I really can't recall if a short story or SF novel or part of a book series. Or when I read it, just "a while ago". Or very much of the plot, all I've got in my mind is the aliens.
They have a long segmented body stretching out behind them with an upright front end. Kind of like a centipede crossed with a centaur.
At mating (I think!) the back segment with its pair of legs splits from the main body, I think it then wanders off in an autonomous manner with the fertilised eggs until it finds somewhere to squat and stay until hatching time. The previously female main body is now left with a male end piece.
The male end, at mating (I think) simply rips off and this leaves a main body that is now female at the end.
Every few years an alien mates and thus gets shorter and shorter until it's a biped.
In the story there was a male who'd had some kind of injury and lost a rear segment but, because no hormonal change had happened, was stuck in the wrong sex.
There may have been some interaction with humans but I really can't recall if there was.
Edit after seeing the proposed answers:- I've accepted the Chaining the Lady suggestion from eshier. However I've looked at the other suggestion from Zeiss Ikon regarding the fuxes of Medea and I think I got the two stories merged into one in my memory.
Thanks to both of you.