Is there an existing official version or rough equivalent of the 4e magic Dynamic weapon in 5e?
The basic properties of a dynamic weapon allow the user to change it from one weapon to another. E.g. Bow then a longsword then a dagger, etc.
This Legendary magic item has the ability to transform into a variety of weapons (among other features):
If you press button 1, the rod becomes a flame tongue, as a fiery blade sprouts from the end opposite the rod's flanged head (you choose the type of sword).
If you press button 2, the rod's flanged head folds down and two crescent-shaped blades spring out, transforming the rod into a magic battleaxe that grants a +3 bonus to attack and damage rolls made with it.
If you press button 3, the rod's flanged head folds down, a spear point springs from the rod's tip, and the rod's handle lengthens into a 6-foot haft, transforming the rod into a magic spear that grants a +3 bonus to attack and damage rolls made with it.
At level 3, warlocks gain access to a pact boon. One of the options to choose from is the Pact of the Blade which says:
You can use your action to create a pact weapon in your empty hand. You can choose the form that this melee weapon takes each time you create it.
In this way, you essentially have a weapon that can take any form. You can even get a few ranged weapons with a particular Eldritch Invocation called Improved Pact Weapon:
Finally, the weapon you conjure can be a shortbow, longbow, light crossbow, or heavy crossbow.