To answer your question yes it is possible and people do it all of the time.
The problems I see when returning are:
- Losing touch with the technology. This is mitigated by looking for companies using older tech when you get back. Not all companies want to use the latest and greatest so they will be more willing to consider you as a candidate
- Losing touch with the working world. If you spend 2 years essentially on a vacation you will most likely have problems adjusting to getting up early to work. Companies know this so they will probably feel that you'll be late to work and suchlike. Mitigation of this would be to adhere to schedule when you are away such that you get up at a normal time and go to bed at a normal time. This might dampen the reason you actually want to do this sabbatical though
- Some companies refuse candidates with gaps in employment. I worked at a company (finance UK) where it was a hard requirement to have no gaps in employment of more than 3 months over the last 7 years or less if you had less experience. You could mitigate this by freelancing during your time off as some companies will count this as working
- In a post CoViD world I see more remote jobs. What affect does this have on you returning. Well previously you could come back to somewhere where there are less candidates than jobs and you'll eventually find something. An example of this is answers here mentioning doing this in the past. I think you'll find tech jobs now are much harder to apply for even locally as a high amount of these jobs will be migrating to LCOL countries
I would look to see the reason you want such a long time off and combined with travelling the world. What can you do right now in your daily routine to satisfy these demands that's less dramatic. That might be working less hours per day or maybe even working part time. In terms of travelling you might want to take more vacations in the year or move to a company that allows that. You can look at the FIRE movement if you just want to stop working and build yourself a path to early retirement.
If it's because you want your life to go back to when you were younger and had a party everyday lifestyle then you need to learn that you must mature. Runningrunning away from everything won't cure these problems in. In fact it'll make you want that lifestyle so bad as your 2 years will fly past.