I don't think defense needs to scale by size per say. After all, because defense works on every attack, effectively adding a lot of defense to a single large ship already gives it a lot more staying power against swarms.
Now I think its a reasonable debate on whether defense is strong enough per module. I personally never put it on tiny and small ships, only on medium do I start to consider it, and then it can be a debate as to whether more defense is really worth the loss of offense.
The other factor is the "overkill scenario". Generally your entire fleet attacks a single ship, assuming it is in range of all ships. If that ship is killed on the first strike, than all other attacks automatically miss. As such, a tiny ship actually soaks a significant amount more damage than its HP would suggest. One way to mitigate that would be to allow each weapon type to fire at a different ship, should the first barrage kill it. This would mean ships with multiple weapon types were more efficient against swarm type opponents, which would be a nice niche for them to have.