The Gemora says that they would make special graves inside the burial chamber especially designed for nefalim (stillborns). This would indicate that there is in fact a mitzvah to bury a neifel.
The Rema in Hilchos Yom Tov (526:10) writes that one is not allowed to bury a neifel on Yom Tov, rather he should be buried the next day.
The source is from the Hagahos Maiomonies who holds that there is no mitzvah to bury a neifel.
However, the Magen Avrohom (20) says that in his opinion, there is a mitzvah to bury a neifel.
The Hagahos Maimonies cites the Gemora in Pesachim (9a) which implies that there was a pit that was designated to throw nefalim into, implying that there isn't any mitzvah of kevurah (burial).
The Gr"a also takes this approach - that the fact that they were thrown into a pit indicates that there isn't a mitzvah of kevurah. But, the Magen Avraham disagrees and holds that being thrown into a pit would qualify as a kevurah. Furthermore, the Magen Avraham cites a proof from the Toras Kohanim which says that a Kohen cannot become tamei for his son or daughter that is a neifel; this implies that there is a mitzvah of kevurah because if there wouldn't be a mitzvah of kevurah, it would be obvious that a Kohen cannot become tamei since he can only make himself tamei for the purpose of kevurah. Finally, he cites our Gemora which says that they would make graves for nefalim, implying that there is a mitzvah of kevurah.
The Magen Avraham concludes by saying that the Gemora in Nidah implies that not only would there be a mitzvah of kevurah for a neifel, but there would even be a la’av (transgression) of ba’al talin (delaying the burial of the deceased overnight).
On this last point, the Noda Beyehudah (OC Kamma, end of 16) says that he doesn’t understand where the Magen Avraham is drawing his proof from that there is a violation of ba’al talin. The Noda Beyehudah argues that logically, the la’av of ba’al talin is a halachah in providing respect to the deceased, which would not apply to a neifel.
The Machatzis Hashekel tries to justify the proof of the Magen Avraham that there would be a la’av of ba’al talin, from Tosafos in Nidah (57) who says that the Cutheans would temporarily bury the neifel with the intent of moving them later. If they were going to move them later, why bury them temporarily? This implies that there would be a violation of ba’al talin that would compel one to bury the neifel temporarily.
It would seem that Tosfos in Pesachim (9a) also holds that there is a mitzvah to bury a neifel. Tosfos writes that the Kohen who leaned over to check if there was a neifel in the pit was a fool. Why? It was because even if it was his own child, a Kohen can only make himself tamei for a viable person, not a neifel. Tosfos continues by saying that the Kohen couldn’t make himself tamei because it wasn’t a need of the deceased. This implies that if it were for the purpose of burying the deceased, he would be able to make himself tamei, presumably because there would be a mitzvah of kevurah (proof to Magen Avraham).
But, perhaps Tosfos means to say that a neifel is always considered not for the need of the deceased since there isn’t any mitzvah of kevurah (like the Hagahos Maimonies).