Hi Yash,
It isn’t possible, and even if it was, it probably wouldn’t be a good idea - if that container restarts after a failure for some reason, any changes to your /etc/hosts would be lost as well.
Note that you don’t have to bring your whole stack down when you make changes ; when you run docker-compose up, Compose will automatically detect what changed in your configuration and only recreate the containers that need it. If your main concern is downtime, this would reduce it significantly, provided your architecture is reasonably failure resilient.