Greece will be forced to withdraw from NATO "finally and irrevocably" and to take over American military bases there if a new formula for Greek membership in the alliance is not found "within the next few weeks," Foreign Minister Constantine Mitsotakis warned today.

"We do not want to do it. We do not want to be De Gaulle," the Greek foreign minister asserted in an interview. "But Greece must return to the alliance, or it must withdraw its application for a return before the Greek elections next year."

Mitsotakis' remarks were the first explicit statement that his center-right coalition, headed by President Constantine Karamanlis, cannot afford politically to go into elections with the NATO question unresolved and American bases still on Greek soil. The election must be held by the autumn of 1981.

His comments also provided an extended public airing of private warnings that the Greeks have been sending to the Carter administration since June. These warnings appear to have intensified following last month's military coup in Turkey.

Mitsotakis said that he had conveyed the warning again this week in a discussion here with Secretary of State Edmund Muskie. Both men are attending the U.N. General Assembly's fall session.

The United States risks losing four major military installations in Greece, including a strategically important naval base and regional electronic surveillance center that tracks Soviet movements in the eastern Mediterranean. Both facilities are located on the island of Crete.

Greece and Turkey are deadlocked over Greek insistence that its reentry into the alliance include operational control of Aegean sea and air lanes as part of NATO's defense planning. Turkey's refusal to agree has blocked the unanimous decision needed from NATO members to readmit Greece.

Karamanlis' government withdrew from the alliance's military structure in 1974 to protest the failure by NATO and the Nixon administration to halt Turkey's invasion of Cyprus. Somewhat like France after Charles de Gaulle withdrew his nation from NATO in 1966, Greece has participated in the alliance's political activities and in limited maneuvers with NATO forces. Athens formally applied for readmission in 1976.

Diplomatic sources in Washington reported that Gen. Bernard W. Rogers, NATO's commander-in-chief, presented Greece and Turkey with a three-point formula earlier this month that would reintegrate Greece into NATO now and decide the Aegean dispute later.

Both sides reportedly agreed to this concept, but continued to dispute whether the eventual settlement would be based on the conditions that prevailed in 1974. Turkey feels that such an arrangement overly favors Greece.

U.S. officials concede that Greece has a legal right to terminate the bases agreement if it is not in NATO. But U.S. officials here with Muskie said they were "cautiously hopeful" that the deadlock could be broken and a crisis in Greek-American relations avoided.

But Mitsotakis appeared disappointed by what he heard from Muskie. The Greek diplomat carefully avoided characterizing the effect he thought the overthrow of Turkey's civilian government would have, but he underlined the urgency that he felt the military takeover has added to the dispute.

"It is crucial that the United States try to persuade Turkey to reach a solution in the next few weeks. The new military government will be taking a position during that time," Mitsotakis said, adding:

"We are not trying to set deadlines or employ blackmail, but this has to be settled well before the election campaign begins."

Turkey's ambassador to the United States, Sukru Elekdag, said in a telephone interview that there would be no change in Turkey's policy on the NATO issue and he asserted that Turkey had done everything it could to reach "an equitable solution. Greece should act reasonably now and not ask the United States to twist arms. We agree that Greece should be reintegrated into NATO, but we cannot accept the violation of NATO's own military principles."

Officials from the two Mediterranean nations said they were not sure when Rogers will make a new effort to reach an agreement.

Karamanlis' New Democracy Party and its allies expect a strong challenge from the left in next year's election, in which the presence of American military facilities probably will be a major issue.