I think you can write whatever you want in a license. Lawyers and tradition don't have supernatural powers or anything. So you could say something like "Non exclusive non revocable license to use this code for any purpose without attribution or fees as long as that purpose is not for training AI, which is never permissible."
Little to no chance anyone involved in training AI will see that or really care though.
Little to no chance anyone involved in training AI will see that or really care though.