We experimentally emulate, in a controlled fashion, the non-Markovian dynamics of a pure dephasing spin-boson model at zero temperature. Specifically, we use a randomized set of external radio-frequency fields to engineer a desired noise power-spectrum to effectively realize a non-Markovian environment for a single NMR qubit. The information backflow, characteristic to the non-Markovianity, is captured in the nonmonotonicity of the decoherence function and von Neumann entropy of the system. Using such emulated non-Markovian environments, we experimentally study the efficiency of the Carr-Purcell-Meiboom-Gill dynamical decoupling (DD) sequence to inhibit the loss of coherence. Using the filter function formalism, we design optimized DD sequences that maximize coherence protection for non-Markovian environments and study their efficiencies experimentally. Finally, we discuss DD-assisted tuning of the effective non-Markovianity.