Run the following three commands to remove the linked and related files with nginx
rm -f -R /opt/homebrew/Cellar/nginx
rm -f -R /opt/homebrew/etc/nginx
rm -f -R /opt/homebrew/var/homebrew/linked/nginx
You will be able to install the nginx afterwards.