Workers always run in front of the Cloudflare cache, so adding a vary header won’t do anything. Could you explain more about what you’re trying to achieve or your current worker code (if any)?
Cloudflare will automatically compress content to end users when the client signals support for gzip (or Brotli) compression. Details available here.
There is an article by @junade that indicates adding the Accept-Encoding header will be ignored and removed, but that may not apply in a Worker.
Doing a quick test on a worker of my own, I see the vary response header when the client indicates gzip capability, and the originless response is compressed as expected.