A person who is a resident in a facility of the department of mental health or in the Bridgewater state hospital and who has funds held in trust for him by the department of mental health or the department of correction, shall contribute toward the cost of any counsel appointed pursuant to chapter two hundred and eleven D to provide representation in proceedings under this chapter, in an amount not exceeding five hundred dollars unless a larger contribution has been ordered by a court pursuant to sections two and five of chapter two hundred and eleven D. Whenever the department of correction or the department of mental health holds funds in trust for such a person, the department shall turn over such funds, but not exceeding five hundred dollars, to the treasurer to be credited toward the cost of providing such counsel.
Mass. Gen. Laws ch. 123, § 18A