Gary Mandel, the 41-year-old lawyer son of former Maryland governor Marvin Mandel, was sentenced yesterday in Baltimore to four months' detention in a halfway house for forging a doctor's signature to obtain a powerful narcotic.

U.S District Judge Joseph Howard specified that the term be served at a Volunteers of America halfway house in Baltimore, with an option for work release. He also ordered Mandel, who was convicted by a jury in September, to perform 150 hours of community service, continue treatment for drug addiction during a three-year probationary period and make "significant efforts to provide financial support for his wife and child."

Fifteen pharmacists testified about Mandel's attempts to obtain more than 20,000 Dilaudid tablets over a two-year period using prescriptions obtained from a Bethesda physician, Dr. Thomas Carter, who treated him for neck pain resulting from a lacrosse injury.

Shortly after Carter stopped writing prescriptions, Gary Mandel allegedly forged four prescription forms to obtain the drug.

Mandel's father, who served 19 months of a prison term for political corruption, spent two weeks at the same halfway house where Gary Mandel was ordered sent. The elder Mandel stayed there shortly before his sentence was commuted four years ago.

Five Lorton prisoners who claimed they were federal employes and requested income tax refunds totaling $8,000 have been convicted in U.S. District Court in Alexandria of filing false government claims.

The Internal Revenue Service, suspicious because the five, who listed their occupations as U.S. Patent and Trademark Office employes, had a Lorton address, sent checks to each prisoner, then kept careful track of them.

The convicted felons either tried to deposit the checks in their inmate accounts at the District of Columbia's Lorton prison complex or sent them to someone outside the prison, according to court records.

U.S. Attorney Kent S. Robinson said inmate John Howard, 33, could be sentenced to up to 80 years in jail and fined $120,000. The other prisoners, Carlous J. Holt, 32, Clayton M. Morris, 38, John F. Wilson, 29, and Robert S. Wylie, 36, could receive up to 20 years in prison or be fined $30,000 or both.