The problem was with the .icns file itself. I had found a dummy icon somewhere on the web, and since it was created incorrectly, it caused this weird behavior.
Important
Make sure to create your .icns file correctly. When using an app to create a .icns file, you should start with a 1024x1024 PNG file to ensure everything looks sharp on Retina displays. If you somehow miss some icon dimensions, such as 64x64 or others, macOS will display blank icons instead of the missing ones.
There are many apps available on the web that can create .icns files for you. A few examples are iLove Icns Creator, Image2Icon, and many others, including command-line utilities.