You will need to bring the floor back to flat. You can rent equipment that will make this a breeze depending on what you have there. If you have soft flexible mastic on the ground must be soft and flexible, you can use a scarifier. If you have mastic that is closer to a cement you will have to use a chipping hammer with a large flat blade. The foam padding will not flatten the floor sufficiently for an install of pergo or any other snap flooring. It will bow and undulate under the weight of a person. It will also likely be noisy or crunchy.
Over a slab it isn't the greatest idea to go with a product like pergo. The mdf can swell with moisture. If you want to go with a thin flooring you'll have to look at the engineered wood floors which are essentially ply wood with a hardwood veneer over the top. They are sandable and stainable but they cost more.