Imagine the party is fighting a dragon of some sort, and the fighter drops his Dragon Slayer longsword after being clawed into unconsciousness. Then I move over and cast Catapult to launch the sword at the dragon.
I know the spell isn't affected by the base damage die of the longsword, but does the Dragon Slayer enchantment deal its extra damage?
Pretty surely not... the Dragon Slayer weapon says:
I mean, it doesn't say "when you hit with an attack", but that's quite obviously the intention. And the Cataput spell is not an attack in that sense. It just does 3d8 damage on a failed save, whether the projectile is a sword or a large bag of feathers.
There is a little bit of ambiguity, because other magic weapons like Dwarven Thrower are clear about what they mean by "hit":
Or Frost Brand:
So possibly you could read the more loose language in Dragon Slayer as including bonking the dragon with the hilt or any other form of contact. But I think that's a pretty big stretch. I think it's much more likely that "hit with this weapon" means the same basic thing in every case.
The Monster Manual (on Page 11, or in the intro section covering monster statistics on D&D Beyond defines "Hit" like this:
... but again, as this is specifically in the context of monster stat blocks, one could make the call that this doesn't overrule the plain-English use of the word in the magic item description. If, as a DM, you'd like to go this way, I think you'd want to come up with some campaign-world-specific reason that mere contact is so damaging to dragons, and consider ruling in a similar way for other magic items to ensure consistency.
Personally, I might allow the loophole in a specific situation: if the dragon is the big boss set-piece encounter of a campaign or at least a major chapter of the campaign, and the party isn't likely to come into situations where they'd be exploiting the extra damage frequently, and the battle is not going their way and this offers a chance to turn the tide with a cinematic "rule of cool" moment — possibly the 3d8 of damage to the sword itself destroys it, releasing a burst of dragon-wounding magic.