I had similar problems when I first tried to export my game using a custom icon. It’s worth noting that there is an official Godot web page for how to do this.
You’ll likely still run into issues following this guide - it’s not very informative and makes a lot of assumptions about the user’s knowledge of .ico files, so I will explain how they work and how to solve your problem. You might actually be experiencing two problems here, both of which will need to be addressed to solve your issue.
.ico files are actually a special type of file that include several smaller images of the same image, pasted over and over again. Opening a .ico file in a photo viewer won’t show these smaller images unless you are using software that is designed to show this.
Thus, simply setting a 256x256 .png image as your .ico file won’t work (nor renaming the file from .png to .ico). You need to generate a .ico file using software.
Fortunately, you can do this easily using online websites. I found this one to work well for me. Just upload your .png and it will convert it into a valid .ico file. If you click “Choose icon layer sizes” you can choose exactly what sizes you want your .ico to work for, but the default settings work fine for Windows.
You need to download rcedit and point your game engine to the file once it is downloaded. You can download it here. The official Godot documentation does a good job of explaining how to point your game engine to the file. If you are running Linux or MacOS, you will additionally need to install WINE, also explained on their page.
I would not place rcedit in the directory of your game (in res://), otherwise it will be exported with your game. Since it is a developer tool, keep it somewhere other than your game directory.
An alternative approach:
If you are on Windows, you could simply export your project without changing the .ico file, then change the executable icon file using Resource Hacker or something similar. This skips the rcedit step. However, it would still require you to have a valid .ico file. It makes much more sense to set it up through the Godot engine. It doesn’t require additional software (besides rcedit) and will do it automatically for you from that point on, without requiring you to manually change it after exporting.
You might be asking yourself, why does a .ico file need to have multiple images within it? Why won’t one image work? The answer is for viewing the executable file in different windows. For example, for viewing on Windows desktop it might need the 256x256 icon, but if you are viewing details/list in the File Explorer, it might need to render a much smaller image of the executable, perhaps the 16x16. You can find more info about that here.