If your site actually needs a web.config
file, then your site isn't suitable for hosting on S3.
You can host a static website on Amazon Simple Storage Service (Amazon S3). On a static website, individual webpages include static content. They might also contain client-side scripts. By contrast, a dynamic website relies on server-side processing, including server-side scripts such as PHP, JSP, or ASP.NET. Amazon S3 does not support server-side scripting.
https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
If, on the other hand, your site doesn't actually need the web.config file, then the file should not be uploaded to a public S3 bucket.
It is possible to deny access to files by name patterns using the bucket policy, or by not setting public-read
for the object itself (assuming the bucket policy doesn't make this setting redundant)... but this solves the wrong problem.