The scenario that you are proposing is related to "Selective Prosecution" or "Malicious prosecution". It refers to the act of using a defendant's race, ethnicity, gender, or creed against them, or allowing these elements to negatively influence a fair due process. When a selective prosecution is proved, a defendant may win a case based on the fact that he or she was discriminated against in the first place.
"A selective prosecution claim is not a defense on the merits to the criminal charge itself, but an independent assertion that the prosecutor has brought the charge for reasons forbidden by the Constitution."
However, that occurrence is very very rare.
In this day and age the advent of the Internet, and the ubiquitous opportunities for leaking privileged information from agencies make it a bit harder to try to get away with selective prosecution. For an act of selective prosecution to be successful there has to be lots of secrecy from each party involved as well as a good way to hide whatever evidence is being tweaked against a defendant.
It is clear that the criminal justice system cannot possibly operate error-free in any case, regardless of whatever color is the defendant's skin, unless all the evidence that would sustain a case in court are present. The due process through which a citizen is prosecuted for the commission of a crime is very specific and filled with steps to be followed. Concisely, in the 21st century it would be quite hard to try to prosecute someone solely based on the person's ethnicity or color without causing a major commotion that could reach social networks, newscasts, the Internet, or any other form of public communication.
This does not mean that discrimination cannot or will not happen EVER, but certainly the possibility of it happening in the 21st century is harder since this is an issue that is consistently under the watchful eye of many civil rights groups all over the world.