One way is via an unbuildable building. Create a building (iCost = -1 so it is unbuildable) and when the conditions are met put it in a city (probably the capital). That one building is set to give a +1xp to every unit built in any city the player owns, like the Pentagon gives +2.
The only real problem with this is that if the city is captured either the effect goes away when the building is destroyed, or it is transfered to the new owner if it is not destroyed. If one of these is the desired behavior, then it isn't a problem.
Random events (which can be non-random, including only hapenning when triggered via Python) can't give XP or make buildings give it, unfortunately (yield, commerce, happiness, heath, or some other things yes; xp no, unless it is applied to one specific unit). But they can give free promotions to all units of specified unit classes or unit combats, applied to all current units of the specified varieties as well as all future units of those varieties. If a free promotion (perhaps a newly created promotion that is pretty weak, like +1 first strike chance or +5% strength) is OK instead of +1 starting XP then you can use a "random" event.
Another option is to set some flag somewhere that triggers the effect in Python, via the onUnitBuilt event. Perhaps a list of civilizations who get the bonus xp that starts out empty. You'd have to save this value somewhere (some object's scriptdata) so that it is stored in a savegame (and possibly in a WB save, which can be more problematic).