Upon the terms prescribed by its legislative body, a local agency may enter into an agreement with other local agencies for the joint construction, ownership, or use of sewage treatment plants and other sewage disposal works or for the purchase or sale of any percentage of the capacity in any such plant or works.