Could you make it so that the "base" unit upgrades to a unit buildable earlier in the game?
It'd still give you the unit, but now you'd have to pay to "downgrade" it. Doesn't really work well.
The better solution would be to change the tech prerequisite of the unit to being something like Future Tech. The game DOES seem to bring era limitations into account, with gifted units and barbarian camps only spawning units appropriate to the era of the players involved. Between the prereq tech, the obsolete tech, and cost, you might be able to create a situation where a unit doesn't get created in 99% of all situations.
Alternatively, how about making it require a resource that will never be revealed?
Wouldn't help. City-states, unfortunately, can gift units that require a resource. Units gifted by Militaristic city-states don't follow any of the usual rules; they're not limited to the units your civ can build, they're not limited by cost, they're not limited by resources, they're not limited by project limitations, and so on. The only thing I've found that MIGHT be linked to the gift status is the <MilitaryUnit> flag. Unfortunately, that flag also seems to be linked to other factors, like the unit's ability to stack with workers, so changing it could have some unfortunate side effects of its own. When I get home I'll play with this a bit more, and let you know what I find.
Now, I'm not saying that what you want can't be done. With Lua, pretty much ANYTHING can be done in one form or another. You can easily trap the creation of the unit with the SerialEventUnitCreated event, and if it's a type you don't want to have created, you can destroy it on the spot and replace it with something else instead. (I'm looking at doing exactly that in my own mod, for both city-state gifts and Barbarian camps.) I believe this same mechanism was being used in the city-state UU mod. It might also be possible to use the CanConstruct GameEvent to do some of this, but I'm not sure if that function applies to gifted units.