A visa is about entry into the United States and, for an H1B, your ability to work for a specified employer while in the U.S. Many U.S. companies employ individuals or hire contractors based in other nations, whether directly or through contractors.
What could create complications is if, rather than hiring you in the capacity of an overseas employee (consistent with your nation's laws) or contractor, they continue to keep you on payroll as if you're still working in their U.S. offices. Not that I would expect that you couldn't overcome the confusion created by such an approach, but it could create both tax obligations and immigration difficulties until the confusion is resolved.

