The Virginia federal judgeship controversy heated up again yesterday with the disclosure that the Carter White House had tried - and failed - to interest Richmond Mayor Henry Marsh in the job.

Marsh, according to sources, was approached about a judgeship by at least three White House go-betweens, including Lt. Gov. Charles Robb. But Richmonds's first black mayor is said to have made it clear he prefers to remain in that post.

The Carter administration - anxious to shore up Democratic support in the only state in the South that the president did not carry in 1976 - also has added Virginia State Democratic chairman Richard Davis to the list of possible nominees for secretary of housing and urban development, according to wire service reports.

Davis said yesterday that he is definitely interested in the HUD post and had heard he is being considered. But Davis said he has not been contacted by anyone from the White House.

Mayor Marsh could not be reached for comment yesterday, but a Justice Department spokesman said the agency had contacted the Richmond official.

Lt. Gov. Robb, while acknowledging that Marsh had been approached, declined to comment or speculate on what he said were behind-the-scenes maneuvers to solve a longstanding judgeship dispute between the White House and Sen. Harry F. Byrd Jr. (I Va.). Carter has criticized the senior senator for failing to include any blacks or women in a list of 10 nominees for the federal bench.

"Events are moving forward," Robb said. "But it would be helpful to me to wait 48 hours before commenting. There's more there, and I'll be happy to talk about it later."

The lieutenant governor said disclosure of the Marsh rejection was "unfortunate . . . it undermines the eventual nomination of whomever is selcted." He balked, however, at the suggestion that the nomination of someone to fill one of two federal bench vacancies was imminent.

Carter threatened last December to leave four new federal judgeships in Virginia vacant until Byrd added blacks and women to the list of 10 white males he had submitted for he White House's consideration. But the president later nominated two attorney's from the Byrd list.

Byrd has steadfastly refused to reopen nominations for the judgeships, arguing the recommendations of two judicial selection panels established to Carter's own urging.

Since last fall, when Byrd released the names of his 10 white male nominees, the Carter administration has made an issue of the absence of blacks and women from Byrd's list. The president has said he is committed to increasing the numbers of minorities and women in high federal posts.

In addition, Sen. Edward M. Kennedy (D-Mass.), chairman of the Senate Judiciary Committee, has said his committee will not act on any judgeship nominations until the president submits candidates for all the vacancies within any judicial district. This has increased pressure on the White House to defy Byrd and nominate a black or a woman in Virginia.

The HUD post, however, appeared to be a different matter. Party chairman Davis, who is also the mayor of Portsmouth and an investment banker, admitted he is interested in the nomination.

"No one has invited me to come to Washington, but I understand that it's true I'm being considered for the secretaryship," said Davis, 57.

Davis said he has had asked to submit a resume for a job as HUD under-secretary or assistant secretary when Carter came to Washington two years ago. Davis later withdrew his name from consideration when he was told he could not return to the mortgage investment business until two years after his HUD assignment ended.

"I want to know more, but in all candor I think I would be willing to bind myself to that agreement now if I was being considered for a cabinet post," Davis said.

The Portsmouth mayor, who is on the executive committee of the Mortgage Bankers Association and also is chairman of the subcommittee on housing for the U.S. Conference of Mayors, said both those groups would like to see someone with that kind of background named to the HUD secretaryship.

The post became open last week when Carter shifted former HUD Secretary Patricia Harris to the Department of Health, Education and Welfare.