Trapping them in a building never worked for me. Even when not aggro i could not feed it. If taming in the desert use a flying combat mount. Use bug spray on the mount and yourself so you can land,dismount,feed and fly off clearing nearby dinos until next feed. This stops it aggroing on your mount and helps you avoid chasing it around on foot losing food/water
There is a great video on how to kill death worms very early game on YouTube by a guy named fresonis which involves using oil jars and flaming arrows to kill it and catch it on fire while it moves underground. This strategy is great for early game players with limited resources as it only takes around 4-5 oil jars and flame arrows to kill a level one death worm. This is a great way to farm horns for mantis taming.
First make sure that the mantis is free from other animals. Take care of the mantis. Hug with a dragon or another big animal that does not attack the mantis. And then you can calmly give him the deadworm horns
Make sure there are no pegomastax around, they will steal every single one of your death horns if they are in your taming bar. They also seem to glitch into the earth even if you catch them so you will lose them regardless. Better to split then up and add them one at a time