Generally you'd phrase your response something like this:
Oh, it's really not for me to say; you'll have to ask him.
That's not really my information to share; you should ask him.
Sorry, I wouldn't feel comfortable sharing that with you without his knowledge.
I prefer not to share personal information at work that I've learned from [meeting / knowing] people outside the office.
In your case, since your boss has already asked the coworker and you know he doesn't want to tell him, you can use something stronger and more final:
I've been asked not to share that information with anyone here.
Or even a simple but direct:
I'm sorry, but he asked me not to tell [anyone / you] about his new employer and I'd rather not get involved in this situation.
That last phrase, "I don't want to get involved", is one you'll probably be using several times in the near future. Just don't engage in a discussion about this. The fact that you know someone outside work doesn't mean that you have to share anything you've learned about them at work.