I had a similar problem with my 06 Honda Civic immediately after a battery change - alarm goes off when the ground lead is connected and tried many of the procedures posted online without success.
Amongst many other attempts, I sorted it out in 4 steps by:
1.) leaving the engine running with all the doors closed (including the bonnet). The alarm turned off by itself after ~15 ear chattering minutes (I guess after the car battery had charged the battery in the siren?)
I found after this procedure, the alarm would go off when I unlock the doors with the fob. This was resolved by:
2.) pressing and holding the unlock button for the first alarm cycle.
At this point, I thought the car was done embarrassing me in front of the neighbors. So I unlock the door (no alarm - looking good so far) and reach in to grab my things. Alarm goes off again (ultrasonic sensor). So I very quickly shut the door, locked the car and called it a day.
The following day, I:
3.) unlocked the door with fob and waited for the auto lock feature to re-lock the car (indicators flash 3 times)
4.) then I pressed and held the unlock button for ~30 seconds or so. I could hear the lock mechanism go a couple of times
This seems to have finally done the trick. Car is now happy (I can lock/unlock and get in and out OK without the alarm sounding off), I'm partially deaf in both ears and my neighbors now hate me. Hope the car stays that way