I want to leave something to a friend, but I would prefer my spouse not to know about it. Is that possible?

Not if you want to leave it to him (or her) in a will, which becomes a public document. You will have to make other provision during your lifetime: for example, you might arrange for your friend to benefit under a life assurance policy (though he or she would still need a copy of your death certificate to be able to claim the money).