Can you flank from above?

If a character is on top of a creature, does this count for flanking?

Context: a group I play in was killing a dragon, and one of my fellow players (a fighter) grappled it and hung on to its neck. One of the other fighters stabbed it on her next turn, and the DM was unsure whether the dragon was flanked or not. Eventually, he said that sure, it was flanked, because technically there was a straight line drawn between the two characters. This group runs pretty heavily on RAF (as evidenced by the polymorph incidents), so this isn’t a “was this right” question. The decision worked for us, but I was curious about what RAW says on it.

Thus: Can you be counted as an enemy for flanking when you are on top of the target? When you are grappling the target? What rules prove this one way or another?

Does the Stirge blood drain allow it to flank as well?

I am playing a Beast Master ranger with a stirge animal companion.

I know that once a stirge is attached to an enemy, it doesn’t need to use its action or anything; Blood Drain’s damage is passive/automatic, with no action required.

If it attaches to the back of an enemy, does that count as flanking (per the optional rule from the DMG) while it’s attached?