### Strictly RAW, using the optional flanking rules from the DMG, this would not qualify for flanking. 

The [flanking rules](https://www.dndbeyond.com/sources/dmg/running-the-game#UsingMiniatures) read:

> When a creature and at least one of its allies are adjacent to an enemy and on opposite sides or corners of the enemy’s space, they flank that enemy [...] 
>
> When in doubt about whether two creatures flank an enemy on a grid, trace an imaginary line between the centers of the creatures’ spaces. If the line passes through opposite sides or corners of the enemy’s space, the enemy is flanked.

Because one player *shared* a space with the dragon, the imaginary lines could not have passed through opposite sides or corners of the enemy’s space, so no flanking.

Here are three conceivable scenarios. In the first, we assume a character is *literally* on top of and sharing the space with the dragon; note, no matter where our ally outside the dragon's space goes can give us two points of intersection with the sides of the dragons space. In the second, the grappling character (center) is not on an opposite side from his allies. The third shows what is necessary for flanking. 

[![enter image description here][1]][1]


Finally, if we do permit flanking rules to apply in 3 dimensions, we still do not satisfy the necessary conditions: the imaginary line does not pass through opposite sides of the dragon's space.

[![enter image description here][2]][2]


  [1]: https://i.sstatic.net/HK5sJ.png
  [2]: https://i.sstatic.net/AOGoJ.png