Earlier quoted context omitted.
B2B. Use an employer of record type setup. You are an employee of a shell in the country you reside, the real 'employer' is just buying a B2B service.
That doesn't help with the tax incentives which is a major driver for why you are seeing significant offshoring. Plenty of major tech hubs in CEE and India give 80-100% tax rebates or PLIs to foreign companies opening and hiring locally IF they also mandate RTO in those offices. They tend to recover the cost through income tax and VAT.
Might be racist but that is going to likely overcome the tax savings on some random guy of otherwise similar software skills in India.