The law says you can't continue a methadone prescription at discharge *for opioid use disorder* unless it is a bridging prescription to a patient's follow up with a methadone clinic and even then it has to be administered one day at a time for no more than 3 days and someone has to observe the patient taking it. It is funny that you can prescribe, say, dilaudid, until the cows come home but methadone for addiction falls under a very strict law.
There have been some interesting studies about very permissive prescribing of buprenorphine during short term jail stays or hospitalizations as a way to get patients into MAT when they may be more open to it and maybe more likely to continue in treatment, but it is not the standard of care.