Legendary Weapons are Purple.
Legendary weapons level up like other weapons, by earning experience as they are used or if equipped when returning a bounty, finishing a mission, finishing a multiplayer match, etc.
However in order to fully upgrade a Legendary weapon you will need a total of 18 Ascendants Energy as well as dozens of Spinmetal, Helium Filaments, Spirit Blooms or Relic Iron. Spinmetal is found on earth, they are white coral looking plants, Helium Filament on the moon, orange/yellow glowing cannisters, Spirit Bloom on Venus, glowing orbs hovering near a plant and Relic Iron on Mars, coppery mounds.
Ascendant Energy can be obtained during Raids. Alternatively it can sometime be rewarded at the end of mutliplayer matches or even more rarely as a reward for completing public events or the result of decrypting an engram.
This can only be earned by fully upgrading a weapon legendary armor will not work.