If necessary, the British government will use a host of devices - everything from diverting his aircraft to dunning him for unpaid gasoline bills - to keep Uganda's President Idi Amin Dada from attending next months' meeting of Commonwealth heads of government here.

Prime Minister James Callaghan, with support from key African Commonwealth leaders, has already decided that Amin would be an embarrassment and should not be allowed to attend. But Callaghan will try to avoid any public announcement of his decision and the government hopes it need never be made.

One reason London does not want to make an open issue of the non-invitation is that are still 301 British subjects, mostly missionaries, in Uganda, and the government here fears that Amin might take revenge on them.

He has ordered the Britons to assemble in Kampala Friday for a lecture on "protocol" and "security." This is regarded here as a thinly veiled threat.

Another reason for avoiding the issue is that Britain and other Commonwealth nations want to maintain the right of each state, as sovereign, to choose who shall and shall not represent it at Commonwealth gatherings.

Amin has passed up several previous Commonwealth conferences, perhaps fearing that he might be deposed in his absence. Since then, however, many of his political rivals have been killed, so such fear might be less of an obstacle to travel now.

In the best of all London scenarios, Amin would simply announce that he cannot attend the meeting sceduled to begin June 8 and would send an ambassador in his place. But if Amin - who insists he is coming with 250 bodyguards and dancers-does make the trip, a series of administrative harassments are planned to keep him out of town. Among them:

Air traffic controllers at London's Heathrow Airport would divert his plane to a Royal Air Force base or even Prestwick Airport in Scotland.

If Amin gets off the plane there, he would be stripped of his bodyguards on the grounds that Scotland Yard has not worked out common security arrangements with them.

Amin would be reminded that he seized power from Milton Obote when Obote was attending a 1971 Commonwealth meeting in Singapore.

Amin would not be permitted outside the airport until Uganda pays thousands of pounds it owes Britain for gasoline.

Amin has been pictured in Britain as a brutal butcher of his own people, and his conduct is thought to be an embarrassment to many of his fellow African leaders. So far, however, they have resisted attempts to condemn him openly in the United Nations Human Rights Commission and elsewhere.

His appearance here would be a distinct domestic political setback for the hard-pressed Callaghan government.

In public, the government has taken the line that Amin's attendance is a matter for all Commonwealth states to decide, not something London could settle by itself. In private, the Commonwealth organization's secretary general, Shridath Ramphal, has been sounding out other leaders in Africa on how to dispose of the problem.

Yesterday Ramphal disclosed a formula. It is up to every state and not the host government to decide who shall represent it, he said. However, the host government - Britain, in this case - has "the duty to insure an environment propitious for the meeting and to guarantee the safety and freedon from embarrassment of all who come."

In plainer English, Ramphal was saying that if Britain decides that Amin's presence would disturb the atmosphere and that his safety and freedom from embarrassment can not be assured, Commonwealth countries will respect a decision to keep Amin out. Amin, in sum, can send anyone he likes except himself.

Ramphal is known to have discussed the affair personally with Presidents Kennth Kaunda of Zambia and Julius Nyerere of Tanzania.

The House of Commons is scheduled to debate Amin's intended visit Friday, when the government's unwelcome is likely to be made clearer.

For the first time, there is even a possibility that Amin's butchery may be rebuked in some form by Third World leaders.

Ramphal, a man not noted for political boldness, will tell the leaders in his reports that the Commonwealth has "a long and necessary tradition of non-interference in the internal affairs of other states."

But he will add, "There will be times in the affairs of the Commonwealth when one member's conduct will provoke the wrath of others beyond the limit of silence. Any other relationship would be so sterile as to be effete. What we must work for is an ethic which constrains meddling but which also inhibits excesses of the kind that demand and justify protest from without."

Ramphal's aides said the subject of these words if Amin.