Cats can and do learn various behaviors through positive behavior training. Positive reinforcement, rewarding a behavior you desire, is how cats learn best, according to the American Association of Feline Practitioners. Ignoring undesirable behaviors can be extremely effective as well. Active punishment is not effective and can lead to a cascade of negative effects.
Source: Tufts Catnip, July 21, 2021. Link.