The justice, appointed to the court by President Barack Obama in 2009, took the relatively unusual step of writing a statement to accompany the nine-member Supreme Court's announcement that it would not take up a criminal case.
Sotomayor took issue with the unidentified prosecutor who, while questioning an African-American defendant in a drug case, asked: "You've got African-Americans, you've got Hispanics, you've got a bag full of money. Does that tell you - a light bulb doesn't go off in your head and say, this is a drug deal?"
The first Hispanic Supreme Court justice, Sotomayor wrote that the prosecutor had "tapped a deep and sorry vein of racial prejudice that has run through the history of criminal justice in our nation."
The question was "pernicious in its attempt to substitute racial stereotype for evidence," she added. Sotomayor also accused the Obama administration of playing down the issue.
The defendant in the case, Bongani Charles Calhoun, wanted the Supreme Court to order a retrial because he said his right to a fair trial was violated when the question was asked. He was convicted of three offenses over his role in a drug conspiracy.
Initially, the administration declined to file a response to Calhoun's claim, indicating government lawyers did not think it merited attention.
"I hope never to see a case like this again," Sotomayor wrote.
Justice Stephen Breyer signed on to Sotomayor's statement.
The court did not take up the case on Monday, because Calhoun had failed to raise his argument earlier in the appeals process, as required under the law, Sotomayor wrote.
At trial, Calhoun's argument was that, although he was present when federal agents arrested him and several other men, he was unaware of the illegal activity.
The case is Calhoun v. United States, U.S. Supreme Court, 12-6142.