(some of the info here might be dated - but still it might show that such a process is indeed recognized by some international laws)
Yes , Since I am travelling really a lot for business, I have encountered them in some (special) situation, although not in Airports, but in walk-in borders , trains or ferries - and usually where the countries have a special relation.
For example , in Zuhai (China) where there is a walking border to Macau , you can apply for a special 3 days Chinese visa at the border itself .
In Shenzen, You can apply for a special 5 days Chinese visa at the border also.
Now, while those situations Can be considered a "visa on arrival" - for Chinese citizens, it is the other way around .
A Chinese citizen can apply for a Macau visa (or respectively - HK) at the border itself BEFORE exiting China .
This can be also done for other non-Chinese citizens that require a visa to HK or Macau ( I do not require one - But I have seen it done there )
Another Example is the walk-in Border between Jordan and Israel when one can apply for a Jordanian Visa BEFORE exiting Israel (there are 3 such borders , I only have done it in one).
Another example are some remote borders (Can not remember the names) between Ecuador and Colombia and Ecuador and Peru, where some years back (actually - a lot) I had a visa made BEFORE exiting the Ecuadorian customs, and the visa was made by Colombian and Peruvian officials INSIDE Ecuador .
India and Nepal (were) another such example - and come to think of it - so does China and Tibet ..
Back to China, in Guangzhou South train station there is a special direct train to HK, where you actually do passport control at the train station (more than 150 km INSIDE china) before boarding the train. A few years back (maybe now also - I do not know) You could have applied for a visa there also (before buying a ticket)
So I guess yes , In some special situations these type of visas exists (or - existed) so they are sanctioned by international law and applied somewhere - although today in the age of e-visas and computers , I guess they are disappearing or will soon .