Convicted cocaine dealer Karen K. Johnson, the former D.C. government employe who was a central figure in a federal investigation of alleged cocaine use by D.C. Mayor Marion Barry, was released yesterday from federal custody after completing her four-month drug sentence.

Johnson, 33, spent more than 11 months in custody, including eight months in the D.C. jail after she refused to answer questions of a federal grand jury probing possible drug use by city employes and was held in contempt of court.

Federal prosecutors had hoped that Johnson's contempt sentence would force her to give evidence against Barry. But when she maintained her silence, prosecutors abandoned the investigation in April.

Johnson was then transferred from the jail to a federally sponsored community center in Southeast Washington where she resumed serving the four-month drug sentence that ended yesterday.

Barry, who last summer publicly accused U.S. Attorney Joseph E. diGenova of attempting to ruin the mayor's political career by trying to link him to Johnson's drug activities, withdrew his criticism when the probe ended. City politicians have said the investigation, which once raised doubts about the mayor's future, has had no impact on his career and that he is in a strong position to make an anticipated bid for reelection next year.

Barry has acknowledged that he had known Johnson through late 1982 and visited her occasionally at her apartment. But Barry, who appeared before the grand jury that indicted Johnson, denied to the grand jury and later publicly denied that he obtained cocaine from Johnson or that he used the drug.

Johnson, a Barry campaign worker during his 1982 reelection campaign, was employed as a $22,217 a year energy conservation specialist at the D.C. Office of Energy until she resigned last August.

She currently works as a $19,000-a-year marketing specialist for the Liberation of Ex-Offenders Thru Employment Opportunities, a nonprofit group that provides job counseling and placement services for convicted felons, according to Executive Director David Molloy. Molloy said Johnson has done "quite well" in the job, which she has had since April.

The eight-year-old group has an annual budget of about $420,000, according to Molloy, and most of the money comes from the city's Department of Employment Services.

Johnson, a California native and the mother of a small child, is expected to continue to work with Molloy's group and remain in the Washington area.

She was at work yesterday, but declined to make a statement.

She will remain on probation for two years.