I don't make plastics, but have added rattles to them, and always used the method Lamar suggested. Add them to the finished bait.
That usually creates a bump in the plastic if it's solid. You can heat up various tools and create pockets for the rattle, but that's time consuming if it's something you're attempting in a production situation.
If you can pour a pocket or slot into the bait, then as has been said, you can use super glues to keep the rattle in place.
I don't recall what the tool was called, but there has been one marketed, that was nothing but a sharpened thin wall tubing, and you inserted it into the plastic to make a place for the rattle. Then it could be sealed in place using heat or glue. Of course even that depends on the bait, as very small, thin baits that may not work well.
You can get thin wall tubing at some craft & hobby supplies. They're usually brass or copper, or could be aluminum. Heat it enough and sharpen an end and you have a core maker for rattles. Then you push the plastic you removed back in the hole and seal it with heat or glue, so same idea.
I've used rattles a lot making flies and jigs. I've found it's been best for making them louder, to not lash them to hooks, and also to have them coated with something like epoxy. Most anything soft seems to deaden the noise, but it's still going to rattle some. That's nothing to do with plastics, just and observation I've found from adding them to flies & jigs.
I have a tube jig mold that allows me to pour them into the jig, and that's a pain to do.