It's certainly possible! My add-on (bit-booster) creates rebases, squashes, cherry-picks and reverts in a secret on-server fork, and then pushes them back into the main repo.
The trick for me (after setting up a special cached local clone directly on the server for the add-on to use) was realizing I needed to use "HookRequestHandle" before doing the "git push". Kinda looks like this:
sloh = new SingleLineOutputHandler();
HookRequestHandle hrh = hookService.registerRequest(fromRepo.getId());
GitScmCommandBuilder commitCmd = gitScm.getCommandBuilderFactory().builder().command("commit");
// [various things here for my "git commit" command...]
cmd = commitCmd.build(sloh);
String result = cmd.call();
Good luck! There's also lots of great examples to learn more about the Bitbucket API out there. For example, YACC (especially @bturner's advice on Issue #139), or my in-progress PR for Auto-Unapprove.
I guess I'm a bit of a @bturner fan...