Correct answer is to disconnect it as stated by Old Geezer and TonyV
But, I've done it. Only used a trickle charger though and wouldn't recommend a fast charger. make sure battery bay has good ventilation and you protect surrounding area from spillage and gassing damage.
I was once told that there was a slight chance of burning out the alternator if the battery was left connected whilst charging.
If you do disconnect the battery remember to get the radio code before you do.