If the Sheriff's office is refusing to return the gun to you, you'll need an order issued by a judge mandating them to do so.
Usually this would be prepared and filed by an attorney. The motion would be prepared outlining what's occurred, and cataloging police impound of the gun.
An order would then be attached for the judge to sign, mandating the gun be released back into your custody.
I understand that retaining an attorney may be an unexpected/ unwanted cost at this time. You can seek out the assistance of an attorney on a pro bono basis.
If you contact the clerk's office at your local courthouse they should have a list of local attorneys who are experienced attorneys, that have voluntarily provided their names to the court to help with pro bono cases like yours.
I hope that helps! Again, I'm so sorry for your loss.
Please let me know if you have any other questions. Also, please take a moment to rate me using the stars at the top of the page, as it's the only way experts are compensated for our time on the site. I do not receive a salary here at JustAnswer, and am only compensated for my time after receiving a rating of 3 stars or more (5 stars are always appreciated). The question won't close after rating, so you can still ask follow-up questions after. Thanks, ***** ***** it!