You can use gio to retrieve this setting or change it.
Here’s an example to set a custom icon on the command line:
mkdir ~/test
gio set -t string ~/test metadata::custom-icon file:///usr/share/icons/Adwaita/scalable/mimetypes/inode-directory-symbolic.svg
double-check:
$ gio info --attributes=metadata::custom-icon test
[...cut...]
attributes:
metadata::custom-icon: file:///usr/share/icons/Adwaita/scalable/mimetypes/inode-directory-symbolic.svg
IHowever, I don’t know how to remove the attribute in order to restore the default.
If you pass an empty string as value, then no icon will be shown in Files as the attribute is still there:
$ gio set -t string ~/test metadata::custom-icon ''
$ gio info --attributes=metadata::custom-icon test
[...cut...]
attributes:
metadata::custom-icon: