I think that if they have passed away , they will not receive your letter. However, if you mean to write to the deceased's family, you could say you are sending your condolences and sympathy to them for their sad loss , and that you are thinking of them in their hour of need. You could add what the deceased person meant to you .
This is a lovely gesture and realy good idea, as this helps with the grieving proccess no matter what your belief system may be,