You're on the right track. Since you asked for "steps" here you go:
Step 1. Choose a safe material:
Consider chemical safety and physical safety. Food grade PLA should be chemically safe, but could be too brittle depending on the design you choose. PETG, T-Glase, or similar filaments (depending on dye) are normally also chemically safe and are less brittle than PLA so may be a better alternative. ABS is NOT typically considered safe for food contact.
Step 2. Choose a safe design:
If using PLA, be sure the design is robust enough to ensure it won't break. Broken rattles with sharp edges make baby...sad. Even less brittle filaments can still break with jagged edges if the design is fragile.
Step 2a. Choose a single piece design:
Choose a design that requires you to add the peas (or other safe filler) during the print such that the finished rattle is fully enclosed. This will minimize parts becoming loose or peas spilling and minimize choke hazards.
Step 3. Consider post processing to improve safety:
Sanding could reduce ridges and minimize crevices that could harbor bacteria, but sealing it with a food-safe sealant may be more effective. There are many sealants that the FDA considers safe, but polyurethane or food-safe epoxy finishes will work well with PLA. (If you use a different material, test to verify good adhesion.)
Step 4. Test:
Make a test rattle and run it through the paces. I guess you could chew on it, but since babies don't have teeth, this might invalidate your data...
Step 5. Consider alternatives such as professional printing services:
If your tests don't inspire confidence, professional services can offer additional materials (metals, ceramics, etc.) that could be safer than a typical fused filament printer.