Magnetic Resonance Elastography (MRE) is performed by the application of motion-sensitive gradients. In this study, RF pulses are designed with an optimal control algorithm to obtain a desired magnetization phase distribution. Such pulse, in presence of a constant gradient, allows to simultaneously perform spatially selective excitation and motion encoding. This offers some advantages when compared to standard MRE encoding strategy. Simulations, phantom and ex vivo experiments show that phase-to-noise ratios are improved. These results demonstrate that optimal control-based pulses can be used to encode motion in the MRE excitation phase with relevant advantages for further in vivo liver rat studies.