In Torcaso v. Watkins, 367 U.S. 488 (1961), the Supreme Court held that
Neither a State nor the Federal Government can... pass laws or impose requirements which aid all
religions as against nonbelievers, and neither can aid those religions
based on a belief in the existence of God as against those religions
founded on different beliefs.
In this case the Court struck down a statute that required state office holders to declare their belief in God as a qualification for holding any office of profit or trust in the state. In this case, Torcaso was appointed as a notary public but was refused his commission when he would not swear that he believed in God.
The Maryland Constitution at the time required a declaration of a belief in God:
[N]o religious test ought ever to be required as a qualification for
any office of profit or trust in this State, other than a declaration
of belief in the existence of God....
Torcaso challenged the constitutionality of the requirement. The Circuit Court rejected his argument and the Court of Appeals (the highest court in the state) held that:
The petitioner is not compelled to believe or disbelieve, under threat
of punishment or other compulsion. True, unless he makes the
declaration of belief, he cannot hold public office in Maryland, but
he is not compelled to hold office.
So Torcaso appealed to the Supreme Court of the US and they made short work of the question and issued a unanimous opinion, concluding that:
This Maryland religious test for public office unconstitutionally
invades the appellant's freedom of belief and religion, and therefore
cannot be enforced against him.
There is no precise method for accommodating your preference. A person who does not want to take a religious oath pretty much just needs to ask for a secular affirmation.