It's hard to know the root cause of any behavior that's not medical, maybe because there is rarely one root cause. You have consulted your (pediatrician?) who said it wasn't medical. If you have concerns in that department, you can always get another opinion.
If it's not medical, it's behavioral. If it's behavioral, you have the fun job of figuring out why she's chosen this particular way of telling you that she doesn't like what is happening to her. (I presumed from your info that it only happens when she's cross for some reason.)
She is 2.5, and she has opinions, desires and feelings about what's happening to her, but no real power to control outcomes or events. It's possible that she feels words are not an effective form of communication for whatever reason. In that case, it's up to you as parents to teach her a good range of feeling words with which she can identify her feelings, and then, listen to what she's saying - not obey, but listen and make her feel heard. Respect that although you may not agree with her, she has a right to her feelings (she'll have them anyway, and it's best to learn how to identify and talk about them). Explain your decisions to her.
Maybe when she has a good emotional vocabulary, this way of expressing herself will stop. Until then, (what I would do if I were in your shoes) respect that. If she wants to close her eyes, it's her decision. She won't hurt anyone (she's not biting or hitting). I would just assure her safety (she's not allowed to walk around with her eyes closed.) I wouldn't let her decision to close her eyes control too much; if you have a trip planned, take the trip. I assume you have a stroller. On the other hand, show respect for all her wishes, and let her have some control over the things she can. She is trying to communicate something besides simple disagreement.
If this is more than just a phase, you'll need to ask for help from a child therapist.