The name of anonymous class is searched and cached when it is first inspected.
The cache is implemented as a hidden instance variable of the class.
If the class is frozen, the cache is failed as the exception because the instance variable is not assignable.
Note that Class.new.freeze.to_s doesn't raise the exception.
This is because Kernel#freeze is redefined by Module#freeze and it caches the class name before freezing.
Kernel#clone is not redefined.
So there is not such trick to avoid the exception.
I'm not sure that it is worth to fix this problem.
object.c (rb_mod_initialize_clone): Override Kernel#initialize_clone
to avoid an exception on Class.new.freeze.clone.to_s.
Reported by Andrew Grimm. [ruby-core:41858] [Bug #5828]