how to add a mouse event on an empty gameobject

I have a game object with a transparent-like rectangular shape image that will serve as a drag bar for my gun barrel. How can you add a function to this object that when I tap/click it the specific actions for the rotation of the gun barrel will be performed.

I already have the script for barrel rotation.

You will need to add a collider (box collider would most likely do the trick) to the game object sized so that it encloses the texture. Then add your script to the object that has the collider attached.

Once you have that you can either add you logic to the OnMouseUp() method.
(Check the scripting reference for MonoBehaviour.OnMouseUp() for an example)

Or you could handle the whole thing ‘manually’ by :

Doing a raycast using your active camera;
Checking which collider has been hit by the ray;
Executing appropriate code based on your specific requirements;

OnMouseUp() approach is a bit easier if you don’t know how to do all the other stuff I mentioned. In either case there are a lot of examples on the forums on how to do all of the above.