Just to expand on what others have said: in this hypothetical, by just resigning as PM, but keeping his position as leader of the party and his seat, the outgoing PM would paradoxically have the upper hand over the monarch.
The monarch has to have someone to form a government, which can command a majority in the House of Commons. Since the outgoing PM is resigning simply because the monarch has refused to follow the PM’s advice, and not because the PM has lost the confidence of his party or the Commons, he’s put the monarch in the difficult position that there is likely no-one else who can form a government in the Commons as currently constituted. That means that the monarch will have difficulty finding someone who can form a government, without calling a general election. And at that general election, the outgoing Prime Minister will campaign, not really against the new PM, but against the monarch, who has intervened in the political process.
There are three examples where this sort of events occurred.
The oldest example was in the UK in 1831-32, over the great Reform Bill. The Whigs under Earl Grey had won an election on the bill, but the Lords were trying to delay its passage. Prime Minister Grey advised King William IV to appoint new peers immediately to ensure the bill’s passage. William declined, and Grey and his Ministry resigned. William called on the Duke of Wellington to form a new government, but Wellington had to decline. Wellington had a majority in the Lords, but the Whigs still had a firm majority in the Commons. Wellington could not form a government.
The King had no choice but to call on Earl Grey to come back, accepting that he would need to follow Grey’s advice as a condition of Grey forming a government. This is the basic precedent for the principle that the PM resigns if the monarch refuses his advice, but also the basic example for how difficult the monarch’s position is if the PM resigns but retains the majority in the Commons.
The two more recent examples were in Canada in 1926 and Australia in 1975. In the Canadian example, Prime Minister King was facing a vote of censure in the Commons and advised the GovGen to dissolve Parliament and call a new election. The GovGen refused to take that advice, because there had been a recent election and King did not have a clear majority in the multi-party Commons - the GovGen thought that in those circumstances, he should call on the leader of the Opposition, Meighen, to try to form a gov’t. Meighen formed a gov’t, but it was defeated in the Commons shortly afterwards. Meighen advised the GovGen to dissolve Parliament and call elections, the same advice King had given, and this time the GovGen did so. In the ensuing election, King ran against the actions of the GovGen, arguing that he had taken too great a role in politics and favoured Meighen over King. King won a majority in the general election.
In Australia in 1975, the GovGen sacked Prime Minister Whitlam and appointed Fraser, the leader of the Opposition, as PM, on condition that Fraser then advise a dissolution of Parliament and a general election on the budget issue which had triggered the dismissal of Whitlam. In the ensuing election, Fraser won a majority.
All three examples show the difficulty which the monarch (or GovGen) faces: if their PM resigns or is dismissed because the monarch doesn’t take their advice, the monarch can only succeed if the political situation is fluid enough for the new PM to gain a majority in Parliament. And, the monarch’s actions will be heavily criticized, for intervening in the political process and going against the will of the outgoing PM, instead of remaining politically neutral.