Yes, H-1B visa holders may conduct remote work from any country. As long as your visa is still in effect, you are free to leave the country and return.