I am sure most of you are already using this technique without even knowing it. as I show in the video, the important thing is to keep the the tone and volume of the notes played with legato as close as possible to those picked. Also remember to play with the tip of your finger when you hammer on, and pluck the string (like you would do with your right hand fingers) when you pull off.
This is the exercise I play at the end of the video: