Semaglutide will fall out of patent protection in 2031 in the US, earlier in other countries. Drug patents do last 20 years (in the US), but the patent date is always some time before the medication is first sold. You also don't get a new patent for finding a new application of the same drug. So a diabetes treatment drug that's now used for weight loss without sufficient modification will expire at the same time as it originally would have even if it gets a new marketing name. Different formulations based on the original drug could get a new patent, though.