All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
It is a Sunnah to straighten the rows in the funeral prayer, just like in the other prayers.
Shaykh Ibn ‘Uthaymeen was asked, “Is it a condition to complete the first row and then the rows which come after it and to fill the gap between the rows in the funeral prayer?
He answered, “The rows in the funeral prayer should be straightened, just like for the rest of the prayers, and one should complete the first row and then the rows that come next, and fill the gaps between the rows.”
Shaykh ‘Abdul Muhsin Al-‘Abbaad, when interpreting the Sunan of Abu Dawood, said:
“What is the ruling on the funeral prayer while the first rows are not complete?
Answer: If the imaam starts the funeral prayer after the obligatory prayer while there are still people who are completing their obligatory prayer, and the praying people could not complete the first rows, then there is nothing wrong with that. However, if they could compete the first rows and failed to do so, then their prayer is not invalid [i.e. it is still valid], but they are sinful because of not completing the rows because the hadeeth reads, ‘If I go forward to lead you in prayer, then imitate me, and those who are after you should imitate you, and there are people who delay until Allah makes them late.’ The same thing applies to the obligatory prayer.”
Based on the above, what is required of you is to pray the funeral prayer, even if those beside you do not pray it, but if you can join some of the rows of the women before the funeral prayer ends, then this is better. The funeral prayer is considered valid even if the rows are incomplete.
Allah knows best.