John McDonnell has doubled down on his pledge that Labour would reject a government of national unity and instead would push for Jeremy Corbyn to form a government or for a general election, in a move that appeared to stymie plans being prepared by Tory rebels.

McDonnell told audience at an Edinburgh festival fringe event that it would be unsustainable for Boris Johnson to remain as prime minister if he no longer had a Commons majority.

The shadow chancellor said that if the Conservative leader failed to quit he would not “want to drag the Queen into this but [he] would be sending Jeremy Corbyn in a cab to Buckingham Palace to say ‘we’re taking over’”.

McDonnell said he expected Labour to win that confidence vote, and said Labour would try to force Johnson out by attempting to form a caretaker government with the support of other opposition parties and rebel Conservative MPs.

Ruling out any deals with the Liberal Democrats or the Scottish National party, McDonnell said the only guarantee to other opposition parties would be to block a no-deal Brexit and organise a fresh EU referendum.

“Again that no means no coalitions or pacts, we just put it there [and] I think people of goodwill who are concerned about the interests of this country, about avoiding a no-deal Brexit, will vote for it,” he said.

McDonnell also rejected claims over the weekend by Johnson’s senior adviser, Dominic Cummings, that it was solely in the prime minister’s gift to decide whether and when to hold a general election. Johnson’s allies have suggested he would delay that election until after he had forced through a no-deal Brexit on 31 October.

“We then have two weeks in which the existing prime minister or anybody else can determine whether they can secure a majority in parliament for a government,” McDonnell said.

“That’s when we’ll be saying Labour can form a majority government and we expect others to come behind us to do that, so it becomes a caretaker government. And part of that will be to say: yes, we will block a no deal and go back to the country in a referendum.

“So that’s the choice that other parties and other MPs will have. Will they support Labour going into government under Jeremy Corbyn to prevent a no deal. I think there will be a majority government.”

If Johnson refused to quit and Labour was unable to form that caretaker government, there could then be a second no confidence motion 14 days after the first where Labour would try to force a general election, McDonnell added.

“Then if necessary there’s a second no-confidence motion if we have to use it. Cummings got it wrong, and other commentators have made it clear, actually that second no-confidence motion will be the one which if necessary we will use to force a general election. No prime minister can sustain themselves in office when they no longer have a majority in the House of Commons.”

Both McDonnell, and the shadow business secretary, Rebecca Long-Bailey, said on Tuesday night they would reject any opportunity to form a cross-party unity government led by anyone other than Corbyn.

Long-Bailey told Channel 4 News the party “wouldn’t countenance a national government of unity” to deal with Brexit.

“What we don’t want is a national unity government that gives Boris some sort of get out of jail free card,” she said.

Several Labour MPs made clear overnight they would be prepared to join cross-party efforts to stop a no-deal Brexit. “The damage caused by this reckless hard Brexit will be felt for generations, it goes beyond party politics,” the Cardiff North MP, Anna McMorrin, tweeted. “I will work with any MP from any party to stop no deal, bring about a public vote and campaign for remain.”

McDonnell also caused friction with Scottish Labour on Tuesday during his interview in Edinburgh by appearing to cautiously back the prospect of a second independence referendum, comments that have fuelled speculation Labour would hope to broker a pact with the SNP.

Asked about a future referendum, McDonnell said: “We would not block something like that. We would let the Scottish people decide. That’s democracy.”

McDonnell admitted Labour was split on the issue, but implied the UK leadership agreed. “There are other views within the party, but that’s our view,” he said.

His remarks, which followed a poll on Monday showing 52% of Scottish voters backed independence, contradict Scottish Labour policy and the formal position of the UK party not to support another plebiscite on independence.