Petroleum jelly, butter ... whatever you got at hand.
Fat doesn't dissolve in water - rain shouldn't be a problem.
Just a lttle wrap around the trunk - it won't harm the tree.
Only downside to this is, that it does not only keep the ants away but some helpful bugs as well.
They even sell this as a commercial product:
https://picclick.de/175m-Fett-Band-Baum-Insektenschutz-Up-Zeit-401221944862.html