Based on my experience 20 years ago you could only renew the H-1B visa in the passport in-country under extraordinary circumstances. In the majority of cases they reject your request and would tell you to travel to a consulate.
Prior to the mid 00s you could renew at any consulate but they changed it so you could only renew in your home country.
the "only in your home country" change happened very recently, late 2025 or early 2026
Not really… Theoretically, you could get it issued in a third country under very restrict conditions (renewing to the same class, in Mexico or Canada, force majeure, etc). However, the likelihood of it being denied was considerably higher, so basically all immigration lawyers strongly recommended going back to the home country.
The recent policy change ended that possibility altogether.
at least for Indians, going to Mexico/Canada and renewing to the same class were both very large use cases. consulate appointments in the home country are super backed up.