Bobby Walker, a former D.C. police officer who was acquitted in February on charges of selling cocaine, was awarded $40,000 by a jury yesterday for malicious prosecution in a suit against the District government, but the verdict was immediately set aside by a federal judge.

Walker, 36, a 12-year veteran of the police force who has admitted using cocaine but denied selling it, was arrested on the cocaine distribution charges in early 1983. He was acquitted by a D.C. Superior Court jury in February.

During trial last week in U.S. District Court here, Walker contended that he was "framed" because he had been quoted in a Washington Post story as criticizing a police captain's policy of "quota arrests." Officers of the police internal affairs unit testified that Walker was arrested as part of an extensive undercover investigation by officers who were unaware of any difficulties he might have had with his superiors.

A jury of four women and two men found in Walker's favor on the malicious prosecution count after deliberating for about eight hours. But they found for the District on three other counts: false arrest, intentional infliction of emotional distress, and violating Walker's civil rights.

A few minutes after the jurors were dismissed, however, U.S. District Judge Norma Holloway Johnson overturned the verdict, ruling that Walker had "not proved by the preponderance of the evidence" that there was malicious prosecution. In her instructions to the jury, Johnson had noted that to win on that count Walker would have to prove not only that he won the criminal case but that it was "initiated without probable cause" and that he was charged for a "primary purpose other than that of bringing an offender to justice."

Assistant D.C. Corporation Counsel Kathleen Carey, who urged Johnson to set aside the verdict, noted that District police had worked closely with the U.S. attorney's office in bringing the case against Walker and that he had been indicted by a grand jury.

Sandy Lee, Walker's attorney, argued that a key witness, Officer A.D. Williams, had lied to the grand jury. Lee said his client would appeal Johnson's ruling.

Walker was fired by the police department in July after a police trial board found him guilty of conduct unbecoming of an officer and using drugs without a prescription because he acknowledged using cocaine, PCP and hashish while off duty. He said he was a "troubled employe" and had used the drugs because of "job-related stress."

Yesterday, Walker said he was appealing his dismissal to the D.C. Office of Employe Appeals.