The Church has not taken a position on this, but most theologians agree that a forced baptism is still valid, but illicit.
On another note, a baby does not have the ability to give or withhold consent. Therefore, it is not a forced baptism.
It was Pope Innocent III who said: “However, he who has never consented, but has altogether opposed it, has received neither the stamp nor the purpose, for it is better to object expressly than to manifest the slightest consent…”
This statement is not ex cathedra, so it is not doctrine. So in short, I guess we really do not know whether a baptism without any consent is valid.