As far as I know, there's no way to train or otherwise cause your pet to be more aggressive. In general, pets don't much care if a monster is friendly to you or not - they'll go ahead and attack anyway, as long as the monster is close to their level.
It's quite possible that your dog has reached max level by this point in the game, especially if he's been getting a lot of kills. However, dogs don't normally attack shopkeepers, even at max level.
I can think of a couple possible explanations for your situation:
- You're wearing a ring of conflict. (Unlikely, since you'd be getting attacked too.)
- Your pet was at maximum level and ate a wraith corpse. This would put him within a level of the shopkeepers and liable to attack.
Some pertinent info from the wiki article on pets:
They say discretion is the better part of valor. Pets don't always possess such discretion, and often find themselves overpowered by opponents they take on. Although a pet will not attack a monster which could kill it in one round, this calculation takes no account of the monster's weapon or passive attack. Be especially careful about bringing dogs or cats into the Gnomish Mines, or horses into shops, especially in the deeper levels. Horses seem especially vulnerable to mimics, and have also been known to attack shopkeepers, as they reach a higher level than dogs or cats. (A pet will not attack a monster which is two or more levels higher than itself. A fully grown large cat or dog is level 9, a fully grown warhorse is level 10, and a shopkeeper is level 11.)
also
Carnivorous and omnivorous pets will eat wraith corpses and gain one level for each, capped at 15 over base level. (There is no cap for gains from engulfing live wraiths.)
I tend to lose my pets pretty early on, so this won't be a great answer. I think the best way to do this is to get a saddle and ride your Dragon. Ridden animals are affected by traps, so I think in the case of a trapdoor you both fall through, although I'm not certain.
The only other way down to the Valley is by level teleport, but I'm fairly sure that doesn't take your pet with you.
Once you're in the Valley, there are stairs leading back up to the Castle. I don't recall whether you can use the stairs to subsequently return. If you can, then you could pick up your pet by coming back upstairs, meeting up, and then walking down again.
Best Answer
All the details are described in this spoiler. The short version is: carry at least one tripe ration so your pet keeps close to you and reward your pet by giving a treat every time it drops something valuable in front of your feet.
Alternatively you can also let your pet fight monsters until it's tough enough to kill shopkeepers, after which you can just take everything in the shop (plus the shopkeeper's money) for free. (Though obviously that takes longer than training your pet to steal if it's still early in the game).