X-Ray is only available for books for sale through Amazon, and all the configuration happens in the Amazon UI.
Leanpub authors who put their Leanpub-generated MOBI files up for sale on Amazon can follow the instructions in this article to enable X-Ray:
https://www.indiesunlimited.com/2017/11/28/tutorial-enabling-x-ray-for-your-ebooks-on-amazon