RAW unclear, RAI magic is lost
Many magic items (namely staves) specify what happens when they are broken. Most don't. If we look at the DMG (pg 141):
Most magic items are objects of extraordinary artisanship. Thanks to a combination of careful crafting and magical reinforcement, a magic item is at least as durable as a nonmagical item of its kind. Most magic items, other than potions and scrolls, have resistance to all damage. Artifacts are practically indestructible, requiring extraordinary measures to destroy.
So, besides artifacts all magic items are broken like anything else, just that they have resistance to all damage. This is basically so they cannot easily be broken, and most likely since it's intended that they cannot be easily repaired. In the case of potions and scrolls there isn't even that, and due to their small size (usually) they are extremely easy to break.
So if by broken you mean dealing enough damage that its hit points are reduced to 0 (the base assumption), then a magic item's magic is lost. Your +1 sword would become a simple, well made normal sword after breaking and repairing by any non-magic-granting means (I guess a wish would easily repair a +1 sword, but not Mending or similar spells).
This is supported by the quote @V2Blast found from Chris Perkins:
What happens if an Eversmoking Bottle is broken? Does the smoke cloud expand on and on forever?
If a magic item breaks, it ceases to function. The eversmoking bottle would stop producing smoke.
So reducing to 0hp = broken, and "If a magic item breaks, it ceases to function". If it's merely damaged, most likely a simpler fix could restore it to a "perfect" state, though many DMs could rule that the magic becomes unstable. No hard rule on "bruised but not broken" magical items, AFAIK.
If you want to realistically "repair" it, just use the crafting magic items rules in DMG 128. If your DM is generous, you might get a discount. Maybe you can homerule something to make magic items easier to repair, but nothing official as far as I know.
Some could argue that "ceases to function" is not the same as "loses its magic". Barring a definitive Sage Advice or an unfound quote, I think RAW is hard to specify. I do think RAI points to broken -> needs to be reenchanted.