Can a clause be added to a terms of use that forbids use of the service if the terms of use would be illegal in the user's jurisdiction?
Yes, but that is redundant because contracts --or portions thereof-- which contravene the law are null and void.
let's say one term of use states that information collected may be retained forever, which is not possible in countries subject to the GDPR
That premise is mistaken in contexts which involve a necessity for the performance of a contract. See recital 40 and article 6.1(b) of the GDPR. That necessity needs to be true (see recital 43) and ongoing (cf. article 17.1(a)).
Likewise, data retention might be required for compliance with a legal obligation to which the controller is subject. See articles 6.1.(c) and 17.3(b)-(e). Depending on the context, the perpetual storing of data might be justifiable under the GDPR.
Accordingly, it is not necessary for the provider to exclude natural persons merely on grounds of the GDPR.