I'm not sure if it can be learned, but read authors with witty styles. Oscar Wilde comes to mind. Essays by Mark Twain are good. Any prose that expresses a sharp mind and good use of language will help you learn how quick thinking and word-play works.