Pregnancy discrimination is against the law under the Pregnancy Discrimination Act. This act covers much more than pregnancy as it extends to all pregnancy-related situations.
The act covers before, during and after any pregnancy, even if it ends in a miscarriage. The Equal Employment Opportunity Commission explains other laws, such as the Americans with Disabilities Act and the Family Medical Leave Act, which also extend your rights for pregnancy-related conditions, including miscarriage.
The general rule is that your employer cannot treat you any differently than it would other employees in the same situation. If your employer does treat you differently, then you would have a discrimination claim.
You may have the right to take a leave from work during and after your miscarriage as you recover. You would have to follow the rules in the FMLA to see if you are eligible. This would provide you with unpaid leave and secure your position for you for when you return to work.
If you require accommodations either during pregnancy to prevent miscarriage or after a miscarriage, you may also be able to secure these under pregnancy discrimination laws. Accommodations must be reasonable and not cause hardship to your employer. As long as they meet these criteria, you should be able to speak with your employer about what you need, and your employer should approve it.
Keep in mind that you can make requests to assert your rights under the various laws, but you need to be sure you and your employer meet the requirements because many laws specify they only apply to employers of a certain size.