1) Not only is it ok but it’s highly recommended. Please continue doing that. And yes you can gift that to any of the Imams or Prophets.
2) So first you make your niyyah of the Khatma (you gift it to so and so marhoom, for example). Then you will say: Oh Allah, I gift the reward of offering my khatma to this marhoom for Imam Mahdi (a). You can do that