Dark matter searches in the gamma-ray extragalactic background via cross-correlations with galaxy catalogs