How to replace .class file of a jar dependency during compilation?

Assume that I added a library to my dependencies

  compile 'com.example:mylib:1.0'

And it includes these .class files:
MyClass1.class, MyClass2.class andMyClass3.class

So during compilation/assembling, how can I replace MyClass1.class with another .class or maybe delete it?

I know who to do this with my source set. Just create a copy task like this:

 project.task("copyClass, type: Copy) {
                from("/myfolder") //which contains some .class files