A toss of a coin was used by a New York City Criminal Court judge to determine the length of a prison sentence in a misdemeanor case. District Attorney Robert M. Morgenthau of Manhattan, who said yesterday that he knew of the sentencing shortly after it happened last Tuesday in Criminal Court in Manhattan, described the actions by the judge, Alan I. Friess, as ''ridiculous and outrageous.''

Judge Friess was censured last year by the State Commission on Judicial Conduct for releasing a woman charged with murder on her own recognizance and then inviting her to stay overnight in his home in Brooklyn. The woman had appeared before him in court in the early hours of Thanksgiving Day in 1980.

Yesterday Judge Friess, in response to reporters' questions about the coin-tossing, said he had given the defendant in a pickpocketing case ''an opportunity for a lesser sentence by allowing him to decide his own fate, and the matter was resolved by the flip of a coin.''

The choice posed by the judge was between heads for 30 days on Rikers Island and tails for 20 days. The toss came up tails. ''The Court felt that the jail time was appropriate, and the District Attorney's office had taken no position on the sentence,'' Judge Friess said. ''The range of appropriate sentence was up to 30 days.''