The simple answer is "no". Casting only succeeds if the object is an instance of the type being cast to, either directly or through inheritance. Make B a subclass of A and you'll be able to use it (almost) anywhere A can be used. If it isn't, you can't.
There are many good reasons for this restriction, including security.
If you really want to redefine A, it's possible to do so to some degree if you have access to the classpath. Put your new A earlier in the classpath, and it will be found first. Of course anything that breaks as a result of doing so is Entirely Your Own Fault, and there will be cases where that breakage will (not may) surprise you -- you won't be able to intermix instances of A from the two different sources. (Having more than one classloader in use, for example, may paint you into that corner.) And anyone you show that solution to may run screaming.
But this is almost certainly an "x/y question". You've jumped to a solution rather than discussing the problem with us. It's almost certainly the wrong solution for the problem. I'd suggest you take a step back, figure out what it is you're trying to achieve by abusing the class system, then ask us for advice on how to do it legitimately.