most of them are synced with your level. f.e many iconics if you grab them late game they are legendary, but mostly will be pick upped during your progress so rare and epic rarity is way more common than legendarys - for example my weapons from jacky are always just rare - because its one of the first side quests I do with a new char to get the bike soonish.
others like the arasaka smartgun is always legendary if I pic it up because I don't care that weapon until very late game where I just grab it if im around the place while doing Kerrys questline. there are also fixer gigs which will drop legendary weapons/gear if you do them on higher lvls - the one gig you need to steal infos for a cop in Watson - the safe in his apartment drops legendary random gear if you are high enough. or you can find a legendary Quasa (?) handgun in the ncpd hustle where you can obtain the iconic Headsman Shotgun crafting spec - again if your lvl is high enough.