Start by going to your custom melee attack montage and opening it. If you do not know how to create a montage find the attack animation you want to use and right click on it in the content browser and select Create Anim Montage.
Once in your montage first set the Slot to DefaultGroup.FireWeapon this is shown in the image below.
Next you need to go to your custom melee attack animation and add the Melee Swing Start notify like in the image below, you can do this by right clicking the Notifies bar then to Add Notify and select the Melee Swing Start option.
You need to position this notify at the point in the animation that you want the damage trace to start (This is when the weapon can deal damage).
Once this is done you can go to your melee weapons holdable blueprint and search for Melee Animations in the class defaults there you can set your new montage.