Attenuating surface gravity waves with mechanical metamaterials