Have a private implementation of the used library and make sure this one gets loaded instead of the real class. (e.g. by tweaking @INC and loading the module early.

examples/fake-module/t/lib/WWW/Mechanize.pm
package WWW::Mechanize;
use strict;
use warnings;

our $VERSION = 'fake';

sub new {
    return bless {}, shift;
}

sub get {
    ...
}

1;