“I will have been working here for 20 years by the time I retire
“I will have worked here for 20 years by the time I retire"
The 2nd while correct, isn't quite natural for my ears. Perhaps I'm biaised and it's a regional/country thing. But for me, I'd say 'would have', rather than 'will have' in this instance.
"I would have worked here for 20 years by the time I retire."
Then (for me) the 2 sentences would be equally natural and just different ways of expressing the same meaning.