I can empathize entirely with your situation! My DD9 is exactly the same way. She will shut down entirely if she outperforms others, specifically with math, and becomes highly anxious. However times in her life when she was grade skipped and her skills were middle-of-the-road, she excelled. It has been so frustrating because she will say she's bored and ask to be challenged, but then does not perform to show her teachers her skill level.
My only ideas (take it for what it is because I haven't found any great solutions either) include:
1. Subject acceleration if she prefers to learn with a classroom rather than differentiated work.
2. Allow her to perform as she is comfortable in school, and work with her on skills at her actual level at home.
3. Try to brainstorm with the classroom or gifted teacher to find a solution.
4. Work with her on building confidence to be different and stand out. Personally, my shy daughter has succeeded with this in sports (playing point guard for basketball and pitching for softball where attention is on her) which has had some crossover with academics.

Good luck, I feel for you. It's hard to find a solution.