This is a case where you need to work with your DM
As other answers point out: no specific rule on magical weapons, making or upgrading.
Just to make sure our terminology is aligned with the current edition, in 5e, Enchantment is a school of magic that is about influencing behavior. (Basic, p 80).
Enchantment spells affect the minds of others, influencing or
controlling their behavior. Such spells can make enemies see the
caster as a friend, force creatures to take a course of action, or
even control another creature like a puppet.
In arriving at "how" you apply the guidance in the DMG (p. 128), a different school of magic looks like the basis for crafting or modifying magical things.
"Transmutation spells change the properties of a creature, object, or
Changing the properties of an object logically fits the school of magic background that leads to someone making an object magical, making one unmagical, or changing the nature of its magical features. (Again, how is very much up to the DM).
Supporting point in RAW:
In the PHB there is a class ability gained at sixth level for a Wizard specializing in the Transmutation school. He can can imbue a stone with magical properties. (Darkvision 60' being one; PHB, p. 119). While that particular magical object is limited to one per wizard, the Transmutation School of Magic fits into what older editions covered in "enchant an item" and other magical item creation schemes.
Chance of Failure
A chance of failure has been part of the "player character makes new magic item" since the original Spell Research rules in O D&D (p. 34, Men and Magic). This basic task a player could do, introducing new magic, and included a chance of failure. That system was gold based, and you could apply enough gold to get to 100% chance of success.
In 5e, the DM running the campaign has a more elegant tool: a DC assigned to any attempt to change the nature of the object. Having a chance of failure fits into D&D 5e's general theme of a reduced availability of magical items.
I could end up ruining Grandpa's sword if I try to make it a +2 blade
What a crafter could do to drive a DC toward a lower number depends on the DM's judgment and the suggestions / ingenuity of the player in coming up with risk mitigation strategies. Get assistance of a Transmutation specialist NPC? Find a scroll with a particular forumula for such an upgrade? (DM would need to provide this formula ...)
The above approach, wherein one could try and either succeed or fail, is consistent with older editions. The AD&D 1e "Enchant an Item" spell had guidelines on purity of materials, time, cost, etcetera. And the attempt could still fail. The casting of a Permanency spell (8th level) spell was usually required to make the magic item work. (This spell typically cost a wizard the loss of a constitution point forever, so it was rare to find).
In the DMG of AD&D 1e (p. 116), the method indicates that magic users can make magic swords, but druids and clerics can only make items related to their class. A consistent theme in that rule set carried over from the OD&D; the provision that "it can go wrong." It has been said that 5e tries to restore some of the original feel. "It can go wrong" was part of that.
Real world analogy: you can put a lot of money into drilling a well for oil and still end up with a dry hole.
D & D's origin included published fiction in magical stories, speculative fiction, and swords and sorcery genres. Sources of this sort can help a DM flesh out / add depth to how his magic crafting requirements are built. A good example of fiction that illustrates how hard it is to make a magical item is a book by Avram Davidson called "The Phoenix and the Mirror."