Seek the services of an instructor who has the knowledge to impart, and can teach it, safely, if you really think it's something you must know.
Yes, it can be taught. The question is whether the "student" is willing to learn it, and ingrain it to the degree that it can be done without having to stop and think about it, with little or no "warning".
If it's a "sequence", the loud noise heard might be accompanied by a sharp pain (or your visual sense going black?). if it's a fluid and subconsciously accessed movement and flow of technique, and the stars and events aligning in your favor isn't a bad thing to have happen, it can work.
Of course, getting your hands on the gun/gun hand, without being shot, is only a part of making it work.
The lesser skilled and experienced (and alert) your attacker is, the better off you might be, too.
Action usually beats reaction, granted, but people generally don't realize
how much they telegraph of their intentions (eyes, posture, preparatory body shifts, etc), including intended movements.
Getting close to the weapon, either gun or knife, also puts
you within arm's (and leg's) reach of the attacker. Sometimes surprise and skill (and some degree of luck?) works, and sometimes horsepower and meanness (the attacker's desire to seriously injure or kill you) may make the difference.
I've never had to disarm someone of a gun, other than in training ... but I've avoided being stabbed slashed at close range by someone seriously intent on wanting to hurt me. It's fast, and even if there's initially talking involved (by the attacker), if you have to think about it, you're probably behind things in the OODA Loop, as visualized and being used
by your attacker.
This is one of those things where the mats the students are sitting on in a training class ought to have little bites taken out of them (by the butts of the seated students). It might be one of those "one mistake" things some people think are easily learned and retained. Recurrent, realistic practice (properly structured and supervised!) isn't a bad thing.
FWIW, one of the first times I faced a live blade was when I was doing some dojo-hopping in the early 70's, looking to visit some notable dojo's (for their eclectic training practices, at times). The first night I was there, I was paired up with a much larger "opponent" (red belt in that system), and imagine my double take when the "knife" he was given to use was an actual fixed blade knife, with what looked like
masking tape along the edge.
Nobody else in the student line up thought it was at all usual (or dangerous). Kept me on my toes. No, I didn't practice "disarming" the fellow, but resorted to "complete immobilization" techniques. Tough dojo. Tough students. Tough times, too. Interesting experience. Happened maybe 6-8 years before that one guy really tried to gut me with a similarly large fixed blade knife.