What happened to the excommunicated if they died without having penance? Could I still pray for such people that God might forgive them their sins?
Excommunication means only that a person is cut off from receiving the sacraments. It does not mean that the Church is sending that person to hell. In fact, excommunication is meant as a medicine to inspire people to repent and be reconciled to the Church. Once reconciled to the Church, that person may again receive the sacraments.
If an excommunicated person dies without being formally reconciled to the Church, he can be saved if he truly and sincerely repents all of his mortal sins before death. Certainly we may pray for such a person that he was interiorly reconciled to God and the Church through full repentance before death.