art 360 covers this in detail:
Art. 360. To Whom Not Extended. Whenever a member of a Lodge commits a Masonic disciplinary violation, or is laboring under charges involving un-Masonic conduct and dies before such charges have been filed or disposed of according to Masonic Law; or in case any member suffers death under circumstances that are discreditable; or that may subject his memory to reproach, the Worshipful Master of the Lodge may refuse to allow him a Masonic funeral.
No expelled Mason shall be accorded a Masonic funeral, and no suspended Mason shall be accorded a Masonic funeral except as otherwise provided in these Laws, but no Mason who stands suspended for non-payment of dues at the time of his death can be restored to membership thereafter by payment, or remission, of such dues.
When a suspended or expelled Mason has been reinstated in a Lodge, subject to approval of the Grand Lodge, and dies before the Grand Lodge has acted, the Grand Master has the discretion to grant a dispensation for a Masonic funeral. No dispensation may be granted where there has been no reinstatement.
The privilege of a Masonic funeral, when requested, shall be extended to Entered Apprentices and Fellowcrafts who die within twelve months of the conferral of the Entered Apprentice or Fellowcraft Degree upon them, or have petitioned and been favorably balloted upon for advancement subject to the other applicable provisions of this Article.
(its also covered in the LIFE program)...