No, you can't 'train' a snake.
Snakes have very simply reptile brains which are devoted to eating and reproduction, and that's it.
The only way you can train any animal is with a reward / punishment system, and a snake's brain is nowhere near sophisticated enough to assimilate such concepts.
Snake charmers don't 'train' snakes - they irritate the snake enough to make it assume a 'strike' pose, with its hood extended. Apart from hunting for food, snakes are essentially passive and will avoid any conflict if they can, but will fight if cornered.
All the charmer does is assume a potential threat pose by invading the snake's personal space, and then weaving movements capture the snake's attention. The music from the charmer's pipe is for the benefit of the audience - snakes do not have ears.
As anyone who deals with snakes will tell you, they are dangerous wild animals, and should be approached as such. If you want a pet to train, get a puppy.