You’d do this on Fly.io much the same way as on any other VM provider! The Fly proxy can redirect http requests to https, but it won’t do host rewrites the way you want. So it’s up to what you deploy in your VM to handle that.
You can create a Docker image that has nginx serving and proxying your Remix application; it’s a valid approach.
Your application can also do this directly, internally. You’d need to examine the request’s Host header and if it’s www.example.com, then you respond with a 301 redirect to example.com.
This is typically done with middleware in your framework that inspects every incoming request. I’m not familiar with Remix, but from what I was able to investigate, typically Express is used as the underlying web server, so if you look for Express middleware for Remix you should find some patterns you can use to get this working.