Using a Washer and a Pencil…
Been using this tip for a few years now for small scribes such as this MDF top for a small cupboard going up to a curved wall etc…
Keep a selection of washers handy in your toolbox, preferably with lots of variation from thin to thick ‘penny’ washers.
Simply measure the front projection to ensure it’s equal, and then run a pencil inside the washer, making sure the washer is tight up to the wall all the way. The washer will follow the undulations in the wall and transfer them into the back edge of the board you need to cut. Use a saw, planer etc to remove the excess material right up to the pencil line. Push the board back to the wall and check your front projection again. Repeat if necessary (usually not).
Hope that’s useful!
Stay well
Ian