In order to customize weapons, you need to build the gunsmith bench. Then you’ll have to find a blueprint, learn it and then craft the modification. To create the modification from resources, place the character next to the right part of the workbench.

Every weapon has a slot for modified parts. Having chosen a slot, you can place one of modifications in there. Depending on the weapon, the number of slots may differ.