I actually figured out another way a few hours ago.
you can go to the prison during the day and cause a distraction to make the guards leave so you can plant the bug. Town hall is also during the day.