Yes, it is valid to carry a child in Salah.
عَنْ أَبِي قَتَادَةَ الأَنْصَارِيِّ، «أَنَّ رَسُولَ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ كَانَ يُصَلِّي وَهُوَ حَامِلٌ أُمَامَةَ بِنْتَ زَيْنَبَ بِنْتِ رَسُولِ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ، وَلِأَبِي العَاصِ بْنِ رَبِيعَةَ بْنِ عَبْدِ شَمْسٍ فَإِذَا سَجَدَ وَضَعَهَا، وَإِذَا قَامَ حَمَلَهَا»
Abu Qatadah al-Ansari narrated that the Prophet ﷺ would pray carrying (his granddaughter) Umamah daughter of Zaynab, daughter of the Messenger of Allah ﷺ, her father was Abu al-Aas bin Rabi’ah bin Abd Shams. When he (the Prophet ﷺ) would make Sajdah, he would put her down, and when he would stand, he would carry her. (Sahih al-Bukhari, 516).
As seen in the above Hadith this was practiced by the Prophet ﷺ therefore it is a valid practice and will not invalidate the Salah. However, one should be careful to minimise movement when picking the child up or putting him down. Also, the Hanafi scholars understood the Hadith in the context of need, so they said it is Makruh if it is done without need.
قلت أَرَأَيْت الْمَرْأَة تصلي وَمَعَهَا صبيها تحمله قَالَ قد أساءت فِي حمل الصَّبِي وَيَنْبَغِي لَهَا أَن تضع صبيها ثمَّ تصلي قلت فَإِن لم تضع صبيها وصلت قَالَ صلَاتهَا تَامَّة
I said, if a woman is carrying her child whilst praying (what is the ruling)? He (Imam Abu Hanifah) said, it is incorrect for her to carry her child (whilst praying) and she should put her child down and then pray. I said, if she does not put her child down and just prays (carrying the child)? He (Imam Abu Hanifah) said, her prayer is complete (valid). (Kitab al-Asl, Imam Muhammad Shaybani).
لَا يُكْرَهُ لِوَاحِدٍ مِنَّا فِعْلُهُ عِنْدَ الْحَاجَةِ، أَمَّا بِدُونِهَا فَمَكْرُوهٌ
And it is not disliked for any of us to do it (pray carrying a child), when there is a need. If there is no need then it is Makruh. (Radd al-Muhtaar).
And Allah (Most High) Knows best.
– Answered by Shaykh Noorud-deen (17.03.2021)
Excessive movement when carrying a child
See also (video):