In short, disconnect and reconnect the board after you change the COM number.
I tested with Windows 10. But this part of Windows has not changed is a very long time.
In testing I changed an UNO R3 to port 256 through Device manager, device properties, Port Settings, Advanced..., COM Port Number and it gave the error mentioned when trying to upload.
Only changing the port number down to 99, 31, and 9 made no difference. However, physically disconnecting and reconnecting the board after each instance of changing the COM number allowed it to upload again, even when that was COM256.
I haven't looked into why reconnecting the board matters where Device Manager listing reflected the change immediately. But I'm also not surprised.