Use some foam tape on your bar or on the inside of the mount. Use two zip-ties (1x4mm max) to attach the part.
I uploaded a version for 22 and 31,8mm handlebars.
Print from any material, I used PLA NX2 matte black. Print with snug supports like shown in the picture.
I also uploaded the f3d. The model is a bit messy, sorry!
The author marked this model as their own original creation.