Hi there. Oh, do I understand inflexible children. I have one myself. His issue stems from sensory issues but none the less, yes. It can be frustrating.
Is your daughter motivated to have friends? That's a really important question because that is the stepping stone for her to change behavior.
You absolutely can not discipline for having a disinterest in playing other people's games on the playground. Kind of a silly suggestion. Not everything comes down to discipline but rather looking for the teachable moments.
If she is motivated to friends and is finding she's not invited to parties, left out on play dates or with kids playing on the playground, instead of shielding her from this, talk about it. Let her know that this is a consequence to not being a great friend. At 8, her peer relations are her business. Not sharing at 8 is something at home you work on by not allowing her to have her way. By this, I mean that you treat her like you are a peer at home. Step in when she is doing something and say "it's my turn!" And take a turn whether she likes it or not. make her share something with you. This is where you can institute some control over her behavior. don't let her go first in games. Don't let her choose what you play but take turns choosing, etc. Dynamics at home with inflexible kids is often better because WE don't really care if we play Sorry or Trouble and WE don't really care if we go first or not and WE don't care if we win. Other kids care. So, you have to recreate the dynamic at home to help her work through the emotions in order to help her.
Many kids do NOT have the skills automatically to get along with their peers. I agree with role playing. I'm not a fan of disciplining for these things unless it is a very tangible thing that you are working on.
For example--- is it bad to want to play what she wants to play only? Not something I'd discipline for but rather help her understand that give and take is part of being a good friend and if she wants friends, she'll have to do this more. Is walking away from kids when one doesn't get their way a bad thing? Not necessarily--- in fact, it sounds like a coping strategy she has developed on her own. Better than a tantrum and yelling and crying! (THAT is more the type of thing to nip in the bud if you see at home with discipline. but you can't discipline at home after the fact.) I would talk to her about other strategies she can work on.
My 9 year old that had some issues with friendships was interesting to work with. I really talked a lot about it wasn't important what you played as much as it was that you connected with a friend. He bought into this and it helped him be more flexible.
Why do you think she's inflexible in play by the way?
Discipline is very appropriate for misbehavior. But it sounds like your daughter may not have the skills it takes to make and/or keep friends or to get along with others. Friendship skills are taught and modeled. A lot of parents that I've worked with take it for granted that kids automatically have the skills it takes to make friends and get along with others. In conjunction to the discipline, I would encourage you to teach and perhaps role play appropriate friendship skills with your daughter.