Yes, I've done it successfully.
In that situation I very much wanted to maintain the friendship, and I felt strongly that if the man in question asked me out and was rejected, then our friendship would have to change.
Admittedly, we were younger, so I've no idea if this would fly now, but I basically sent him an email acknowledging that I'd heard rumours he was keen. I told him how much I valued his friendship and said that I was flattered but not attracted to him in that way.
I also gave an all important out - that I hoped I wasn't embarrassing myself if the rumours weren't true, and if that was so, he could just ignore the whole email.
So - he got to pretend he was never going to ask me, and I got to keep a good friend.