That’s the holding in Friday’s Doe v. Acton-Boxborough Regional School Dist. (Mass. May 9, 2014), applying the Massachusetts Constitution’s equal protection provision. (Other courts that have considered the issue under the U.S. Constitution’s Establishment Clause and Equal Protection Clause have generally held the same; see, for instance, Newdow v. Rio Linda Union School Dist. (9th Cir. 2012).) Here’s an excerpt from the court’s reasoning:

Here there is no discriminatory classification for purposes of art. 106 — no differing treatment of any class or classes of students based on their sex, race, color, creed, or national origin. All students are treated alike. They are free, if they choose, to recite the pledge or any part of it that they see fit. They are entirely free as well to choose to abstain. No one is required to say all or even any part of it. And significantly, no student who abstains from reciting the pledge, or any part of it, is required to articulate a reason for his or her choice to do so.

Though no Establishment Clause claim (state or federal) was brought, the court did discuss the Establishment Clause issue, citing and quoting an earlier opinion on the subject from the federal First Circuit:

The plaintiffs in that [First Circuit] case, similar to the plaintiffs here, maintained that the recitation of the pledge would effectively cast them as outsiders. As part of its discussion of the so-called endorsement mode of analysis, the First Circuit acknowledged the principle that “[a] practice in which the [S]tate is involved may not ‘send[] the ancillary message to members of the audience who are nonadherents “that they are outsiders, not full members of the political community, and an accompanying message to adherents that they are insiders, favored members of the political community.”‘” The court rejected the plaintiffs’ claim that there is such a message sent when the pledge is recited voluntarily:
The same can be said of the plaintiffs’ [Massachusetts Constitution] claim in this case. Participation is entirely voluntary; all students are presented with the same options; and one student’s choice not to participate because of a religiously held belief is, as both a practical and a legal matter, indistinguishable from another’s choice to abstain for a wholly different, more mundane, and constitutionally insignificant reason.
The plaintiffs nevertheless press the claim that the children are adversely affected by the recitation of the pledge because of their religious views. They claim to be “stigmatize[d]” and “marginalized,” and to “feel excluded,” when the pledge is recited by others, regardless of whether they participate. Specifically, they contend that having the pledge with the words “under God” recited in their schools effectively conveys a message that persons, like them, who do not believe that the Nation is “under God” are “outsiders,” “second-class citizens,” and “unpatriotic.”
The plaintiffs do not appear to be claiming that their children have been punished, bullied, criticized, ostracized, or otherwise mistreated by anyone as a result of their decision to decline to recite some (or all) of the pledge. There is no evidence in the summary judgment record that the plaintiffs’ children have in fact been treated by school administrators, teachers, staff, fellow students, or anyone else any differently from other children because of their religious beliefs, or because of how they participate in the pledge. Nor is there any evidence that they have in fact been perceived any differently for those reasons. The plaintiffs do identify what they claim is a poor public perception of atheists in general, and they maintain that their children’s failure to recite the pledge in its entirety may “possibly” lead to “unwanted attention, criticism, and potential bullying.” However, there is nothing in the record indicating that this has in fact happened to the plaintiffs’ children or to any other Massachusetts schoolchildren because of their decision to exercise their right not to recite the words “under God” in the pledge. In short, there is nothing empirical or even anecdotal in the summary judgment record to support a claim that the children actually have been treated or perceived by others as “outsiders,” “second-class citizens,” or “unpatriotic.”
The plaintiffs’ claim of stigma is more esoteric. They contend that the mere recitation of the pledge in the schools is itself a public repudiation of their religious values, and, in essence, a public announcement that they do not belong. It is this alleged repudiation that they say causes them to feel marginalized, sending a message to them and to others that, because they do not share all of the values that are being recited, they are “unpatriotic” “outsiders.” We hold that this very limited type of consequence alleged by the plaintiffs — feeling stigmatized and excluded — is not cognizable under [the Massachusetts equal protection provision].

Note that the voluntary nature of the pledge isn’t just a matter of state law. The Supreme Court ruled in 1943 that, because of the Free Speech Clause, any recital of the pledge cannot be legally required of students. That is at least equally true for the “under God” part.