In Lua, nearly anything is possible.
In XML, not so much.
You CAN make Building yields increase at certain technologies; currently the only building that uses this functionality is the Mughal Fort, which gains (I think) +2 gold at a certain technology. You can't directly double the Library's bonus outright, because it's not that sort of yield, but you could use this mechanism to say that the Library gains a flat +2 research at a certain tech, on top of its normal effect. In most cases you'd just be better off putting that +2 on the next building in line, but it can be done.
As for the second part, no, you can't do that. You can get somewhat close to that effect by creating a new National Wonder and having it bestow a custom promotion on all of your units once complete, which would effectively tie the trigger to a technology, but there also aren't promotions that tweak the fortification bonus like that. At best, you could make a promotion that gives a bonus to units that defend, or that fight within your own territory, or something along those lines.