Dattaka or adopted son is familiar term in all Dharmasutras and Smrti texts. But it seems to be mostly covered in Manusmriti and Vavsistha Dharmasutra.
But first as per Manusmriti
9.182 Among brothers, born of the same father, if even one have a son, Manu has declared all of them to be ‘with son,’ through that son
So one need not go through the adoption route if husband has nephew(s) through his brother(s). Brother's son is sufficient to secure the spiritual benefits.
However assuming the above condition is not satisfied then the requirement is that the adopted son is not the eldest son or the only son of his biological parents
Vasishta Chp XV
But let him not give or receive (in adoption) an only son;[2]
For he (must remain) to continue the line of the ancestors.[3]
The process is described as follows.
He who desires to adopt a son, shall assemble[5] his kinsmen, announce his intention to the king, make burnt-offerings in the middle of the house, reciting the Vyāhṛtis, and take (as a son) a not remote kinsman, just the nearest among his relatives.
But if a doubt arises (with respect to an adopted son who is) a remote kinsman, (the adopter) shall set him apart like a Śūdra.[6]
Keep in mind that the adopted son needs to be somewhat related. Remote kinsman seems to be defined in the following order - Sapinda, Samānodaka and Sagotra. The last one Sagotra meaning from the same 'Gotra'
Finally there seems to be scriptural support in form of example-
As per Aitterya Brahmana, Vishvamitra adopted Sunassepa under the name Devarata even though the former had Aurasa (legitimate) sons as they had become incapable of performing religious rites. So even adopted son can satisfy the debt to ancestors.
P.S. There is an entire treatise Dattakamīmāṃsā written by Nandapaṇḍita in the 16th century AD on adoption, incase someone wants to dig deeper.