I heard this recommendation from Steve Ray on Catholic Answers Live one time –
Start doing a family rosary at home. Get your child his/her own rosary and help them follow along as much as possible. Don’t let him/her run around or be loud during the devotional time; expect them to behave as they would need to at Mass and give instruction in this area accordingly. If you can get them to behave during a family rosary, then having them behave at Mass will be easier, and a family prayer time benefits everyone.
Other recommendations (I have a two-year-old so I know what you’re going through!):
Have a special toy that your child can only play with during Mass. For my daughter, it’s a travel-sized Magna-doodle (she loves to color and draw).
Make sure you have a sippy cup of water and perhaps some portable, non-messy snacks along. Eating is a great distraction for little ones.
Try to quietly point out interesting items during the Mass to keep his/her attention – “What color is Father wearing? Where is the cross? Where is the water? Look, there’s Jesus! Do you see Jesus?” [during the Eucharist] and so on.
Picture books, especially religious-themed ones, are a good idea too.
It is not easy, but the best of luck to you and your family.