GREENFIELD — The town is joining a class-action lawsuit against three major pharmaceutical companies in an attempt to recoup costs associated with a spike in drug overdoses in recent years, according to Mayor William Martin.