While Ronny’s answer works it forces you to change application code. In general you should not do this for the sake of testing.
Instead you can explicitly patch the object in the second package. This is mentioned in the docs for the unittest module.
monkeypatch.setattr('another_package.bar', lambda: print('patched'))