My daughter was the same way. She wasn't scared, but she just chose not to go. She would hold it, literally, until we picked her up from school (they only went from 8-11:45 and she could hold it for a LOOOONG time). It basically boiled down to the fact that my daughter's personality is one of following the rules. That means... if the class was told to work on x project, she would sit in her chair and work on x project.
She once wet her pants because they were in reading group. And the rule was that you only talked in reading group when it was your turn to read. So she wouldn't even raise her hand to ask to go to the bathroom b/c it didn't happen to be her turn. This is a child that was fully potty trained at 2 yrs old and had never wet the bed.
I think you need to make every effort to let your daughter know that the rules are the rules, yes, but there are exceptions and no one, especially her teacher, wants her to feel like she can't use the potty. EVERYONE has to use the potty. It is just part of the way our bodies work. Be sure and talk with her teacher(s) so that they understand she needs encouragement and "comfort" about going... if she is forced to "announce in front of the class" that she has to go, she might choose to avoid the embarrassment and try to wait it out. Maybe there is a "secret" signal that they can work out... where she might raise her hand and LOOK at the bathroom (isn't there one in the classroom?) and the teacher could give her a nod letting her know it is okay... without her having to SAY what she needs. ? Or perhaps she can get approval to approach the teacher (even when the class is required to be seated) in a more private manner to ask to go.
good luck. It was very frustrating for us... but we got through it. It lasted almost all the way through kindergarten with our darling. But she DID get past it and it wasn't caused by anything sinister going on.