President Reagan acknowledged last night that formation of a right-wing, anti-reform government in El Salvador would create "great difficulties" for U.S. policy, but he refused to say whether he will continue military and economic support if rightist forces win power there.

"For the moment, I'm going to be optimistic about what happens there and avoid a specific answer," the president said at his news conference in response to a question whether he would back a Salvadoran government containing extremist figures such as cashiered army officer Roberto D'Aubuisson.

Instead, Reagan sought to keep attention on his administration's contention that the high voter turnout in the Salvadoran elections last Sunday represented a repudiation of the violent tactics of leftist guerrillas in that country's civil war.

He told of a visit yesterday by Sen. Nancy Landon Kassebaum (R-Kan.) and other U.S. observers at the elections and said that their descriptions of the voting were reason for Americans "to be inspired by what went on down there."

The observers, Reagan said, told him of one woman who, although wounded by a ricocheting bullet, refused to leave the voting line, and of another who defied leftist threats by telling the guerrillas they could kill her and her family but could not kill all those who wanted peace.

He cited these examples as reasons why the administration prefers for now to watch the progress of efforts to form a new Salvadoran government and not commit itself on which groups it will or won't support. But he also admitted: "It would give us great difficulties if a government appeared on the scene that backed away from the reforms we have supported."

That has loomed as a possibility since the vote count revealed that D'Aubuisson's National Republican Alliance, known as ARENA, and four other rightist parties have the strength to form a coalition that could exclude the centrist Christian Democratic Party of Jose Napoleon Duarte, president of the outgoing U.S.-backed junta.

The United States, through its embassy in San Salvador, is known to be working behind the scenes to ensure that the Christian Democrats are in the new government and that D'Aubuisson is excluded. But, the administration, recognizing that it might have to accept some rightist participation, has put its stress publicly on emphasizing the election success and its belief that what counts now is not which parties are in the new government but whether they support continued reform.

Earlier yesterday, the president sought to underscore that point by making public a letter to the Salvadoran people in which he called the elections a "moving demonstration of the popular will" and said: "The Salvadoran people have clearly repudiated violence and voiced their commitment to a democratic future."

The administration also brought Kassebaum and other observers to a White House news conference. But their attempts to describe their impressions were turned aside as reporters shouted demands for the administration to clarify its position on support for a rightist government.

The observers and administration officials, taking the same line later used by the president, replied that such questions are premature. Everett E. Briggs, deputy assistant secretary of state for inter-American affairs and a major architect of the El Salvador policy, said:

"I don't really see the point of trying to anticipate what the outcome of these efforts is going to be. It's too early to say. What we've seen is the beginning of a democratic process. Now we'll see in due course how it turns out."

The administration also ran into controversy over another major element of its Latin America policy yesterday when the AFL-CIO called for Reagan to drastically revise his proposed aid and trade package for the Caribbean basin. The AFL-CIO told the Senate Foreign Relations Committee that, while it supports economic aid to the region, it strongly opposes those concessions and incentives aimed at encouraging investment as job-exporting measures that would increase domestic unemployment.