Mayor Marion Barry has signed a $39 million contract to dispose of sludge produced at the Blue Plains sewage treatment plant with Dano Resource Recovery Inc., an Alexandria firm that previously tried to do the job but failed, it was announced yesterday.

The contract calls for the Dano firm to build a facility at Blue Plains in far Southwest Washington that will convert around 900 tons of sludge a day into fertilizer to be bagged and sold, according to Carroll B. Harvey, director of the city's Department of General Services.

Barry signed a similar $20 million contract with Dano last year, although the firm had never before done that kind of work. The city was to pay Dano $11 a ton to dispose of the material.

But so far, the company has not hauled away an ounce of sludge. Nor has it received any of the $20 million.

Under the terms of last year's contract, the firm sought to build its sludge disposal facility in King George County, Va. But the project met with community protests and concerns about air quality, and county officials revoked a building permit.

The Dano firm had tried before, and failed before, to find a place to dispose of D.C. sludge. In 1977, the company made its first proposal to build a processing plant in Prince George's County, Md. The county refused to grant the necessary permits, however.

The company then tried Prince William County, Va., in 1978, but again, the necessary permits were refused by county officials. Then came an unsuccessful attempt to find a site in Stafford County, Va., where once again permits were refused.

Then followed the ill-fated King George County proposal. Company officials arranged to buy 195-acre estate on which to build the disposal plant, then acknowledged that the purchase had been set up in the name of a dummy corporation. The owner of the property had been told that the land would be subdivided into smaller residential estates, Dano vice president Robert M. Picardat acknowledged in 1979.

Meanwhile, the District has been paying $45 a ton to have its sludge hauled away for disposal in Montgomery and Prince George's counties. The city is under a federal court order to find some way of handling its share of the sludge produced at the regional Blue Plains plant.

Harvey said that under the new five-year contract the city will pay Dano $24 a ton to get rid of the sludge. He said the company was awarded the contract because it came up with the lowest competitive bid for the job.

Residents near the other sites sought by Dano for its plant said they feared the facility would generate unpleasant odor. In the past, Washington residents living near Blue Plains have sought to block expansion of the plant. But Harvey contended that the new disposal facility should actually improve the air around Blue Plains.

"The sludge will go through a mixer that will help get rid of the odor," he said. "Virtually nothing can escape." Presently, he said, odors arise as the sludge sits untreated at Blue Plains for a period of time, awaiting disposal.

He said the company will be required to post a $14 million bond to ensure construction of the plant and another $1.5 million bond to guard against mishaps during operation. The plant is scheduled to be completed in July 1981, Harvey said. Until that on time, he said, the city will continue disposing of the sludge at the $45-a-ton.

Harvey said that although Dano has never operated the kind of facility envisioned, the disposal process to be used "is in operation in hundreds of places around the world." He said that to reassure the city of its ability to handle the job, the Dano firm hired an engineer who previously managed a similar plant in Leicester, England.

Officials of Dano Resource Recovery Inc. could not be reached for comment.