It clearly is OK sometimes: almost the opposite case to what you describe, i.e. when a faster cyclist has been gaining for a while but finally catches up at the lights, or has been stuck behind unable to pass because of passing cars. I've been in both sides of this situation and will sometimes invite obvious fast cyclists to get away ahead of me.
Without condoning red-light running, some people get away very early at lights. I'd rather they were in front of me than behind, itching to overtake. I've got enough to worry about with the cars.
I've seen cyclists stop so far back in a bike box that there's no safe place behind them (with big vehicles around). Often these are the slow cyclists who don't position themselves clearly on front of cars but sometimes they're fast riders who don't want to unclip and are leaning on something. The sort of riders I'd normally let past. In this case a little discourtesy is less important than avoiding being in the blind spot of a bus turning the corner. That could be considered a general rule.
Any kind of jockeying for position is not OK unless preceded by an agreement to race, to which my response would be "you go ahead".