This is just a simple idea to add a little more RNG to the game. The first part needed has already been done, the ability to remove and add legendary effects to any armour and weapon. There are a few mods that do this. The next part may be a bit harder, have all the weapons and armour in the game come with 0-5 legendary slots. The higher the enemies level, the higher the chances of getting something with more slots. I just think this could be an interesting thing to add.
One way of doing this, would be to make duplicates of existing armour and weapons with fixed amout of slots and just put them into a level list. That would mean there would be 6 of everything in the game, but this may be the easiest way of doing it.
Another way could be to have a script add a random number of slots to anything that is picked up, that may be hard to do, or is not doable at all.
The level list for them could look something like this:
0 Slots: level 1-80
1 Slot: level 10-90
2 Slots: level 30-110
3 Slots: 50-130
4 Slots: 70-150
5 Slots: 90~