Four former employees of Hewlett-Packard Co. have filed a lawsuit alleging they were victims of age discrimination as the technology giant pared its workforce in recent years.

Their suit, filed Aug. 18 in the U.S. District Court in San Jose, Calif., alleges violations of California and federal laws and seeks class-action status on behalf of other workers who were 40 years old or older at the time they were laid off. It names Hewlett Packard Enterprise Co. and HP Inc., the two companies formed when Hewlett-Packard broke up...