It is safe and it in fact bars you from getting any medical problems associated with intercourse such as sexually transmitted diseases. However, if you are at a high risk for premature delivery or have problems with the placenta and have experienced unexplained bleeding you should abstain from masturbating or even sex for that matter.
Your OB/GYN will tell you one way or another. Usually yes, sometimes no, with some high risk pregnancies. Call your doctor's office. If yes, "you go girl." (Is that the right use of that phrase? I never know.)
You would be best to check with your OB/GYN, but normally yes.Sex will eventually become uncomfortable and you will have to be cautious,but this should be perfectly fine.Just because you are pregnant doesnt mean you can't still have some fun.