Create/add a service worker js. in root directory

I would really like to be able to add a ‘service worker file’ in the root directory. Can’t install messaging apps otherwise. This will really help and need this to have firebase messaging. As instructed by one of the apps I really would like on my site…below is a screenshot of instructions on what needs to be done.