Per IRS Frequently Asked Questions Dependents webpage:
Question: My child was stillborn. May I claim my child as a dependent on my tax return?
Answer: In order to claim a newborn child as a dependent, state or local law must treat the child as having been born alive, and there must be proof of a live birth shown by an official document like a birth certificate. Due to these requirements, you may not claim a stillborn child as a dependent.
Per IRS Publication 501 Dependents, Standard Deduction, and Filing Information, page 13:
Death or birth of child. A child who was born or died during the year is treated as having lived with you more than half the year if your home was the child's home more than half the time he or she was alive during the year. The same is true if the child lived with you more than half the year except for any required hospital stay following birth.
Child born alive. You may be able to claim as a dependent a child born alive during the year, even if the child lived only for a moment. State or local law must treat the child as having been born alive. There must be proof of a live birth shown by an official document, such as a birth certificate. The child must be your qualifying child or qualifying relative, and all the other tests to claim the child as a dependent must be met.
Stillborn child. You can't claim a stillborn child as a dependent.
Note that any link in the information above is updated each year automatically and will take you to the most recent version of the webpage or document at the time it is accessed.