Court scenes in American movies, television, and books typically show people swearing an oath to tell the truth, the whole truth, and nothing but the truth. Usually they swear an oath "to God" and with a hand on the Bible. Such scenes are so common that most people seem to assume that it's required, but it's not. You have a right to just "affirm" that you will tell the truth, the whole truth, and nothing but the truth. No gods, Bibles, or anything else religious need to be involved.
This is not an issue that only affects atheists. Many religious believers, including some Christians, object to swearing oaths to God and would prefer to affirm that they will tell the truth. Britain has guaranteed a right to affirm rather than swear an oath since 1695. In America, the Constitution specifically references affirming alongside swearing at four different points.
This doesn't mean that there are no risks involved if you choose to affirm rather than swear, but it does mean that atheists aren't alone in this preference. Given that there are many political, personal, and legal reasons for affirming rather than swearing, it means that you should probably making this choice when the situation arises.
Why Should Atheists Affirm Rather than Swear?
There are good political and ideological reasons for affirming an oath rather than swearing. Expecting people in court to swear an oath to God while using a Bible only helps reinforce Christian Supremacy in America. It's not just a "privilege" for Christians that courts incorporate Christian beliefs and text into legal procedures, but instead a form of supremacy because they are receiving official state approval and citizens are expected to actively participate. Even if other religious texts are permitted, it still means that the government is favoring religion in an inappropriate manner.
There are also good personal reasons to affirm an oath rather than swear. If you acquiesce to participating in what is effectively a religious ritual, you are making a public statement of approval of and agreement with the religious underpinnings of that ritual. It's not psychologically healthy to publicly proclaim the existence of God and moral value of the Bible when you don't actually believe any of this.
Finally, there are good legal reasons to affirm an oath rather than swear. If you swear to God on a Bible when you don't believe in either, then you doing the opposite of what you are supposed to. You cannot reliably promise to tell the truth in a ceremony where you are lying about your beliefs and commitments. I don’t know if this could be used to undermine your credibility in current or future court proceedings, but it is a risk.
Risks to Atheists in Affirming an Oath
If you ask in open court to be permitted to affirm an oath to tell the truth rather than swear to God and on a Bible, you'll be drawing a great deal of attention to yourself. Because everyone "knows" that you swear an oath to God and on the Bible to tell the truth, then you will attract attention even if you make arrangements ahead of time. It is more likely that this attention will lean negative because so many people associate morality with God and Christianity. Anyone refusing or failing to swear to God will thus become suspicious to at least a percentage of observers.
Prejudice against atheists in America is widespread. If you are suspected of being an atheist, or even of just not believing in God the way most people do, then judges and jurors may be inclined to give your testimony less weight. If it is your case that is being dealt with, you may become less sympathetic and thus less likely to be victorious. Do you want to risk losing your case or hurting the case you favor? This is not a risk to be taken lightly, even though it may not be very likely to lead to any serious problems.
So while there are plenty of political, ideological, personal, and legal reasons to affirm rather than swear, there are very strong pragmatic reasons to simply keep your head down and not contradicting anyone's expectations. If you conclude that it is best to affirm rather than swear an oath, you should do so only if you understand that risks are involved and if you are prepared to deal with them. At the very least, it would be a good idea to talk an officer of the court in advance about affirming rather than swearing.