I have done this, and whilst it is fairly straight forward, there are a number of points that you should follow for safety.
The battery must be securely anchored in the boot, so it wont move when the car accelerates or brakes.
When a battery is charged, it can produce hydrogen gas which is highly flammable, It also contains acid, so the battery must be in a box, which is vented to the outside and sealed to the interior of the car. Some batteries have a spigot for a small ventilation pipe moulded into their casing.
Both charging leads and clamps must be property insulated and I say both should be fused - others say only the positive needs fusing at about 10A.
I actually use a close fitting industrial plastic tote box with a sealed lid. I am able to strap it to the boot floor using the load rings in my car. I use a cable with fuses and battery clamps connected to a 12S plug, which I can trail out through the soft seal of the boot lid and to the tow bar sockets. I also have a vent pipe that will pass through the boot lid soft seal without collapsing.
This may not work with all cars, where the boot lid seal is less compliant. In which case a more permanent installation may be necessary by drilling through parts of the body work.
I fitted a plastic vent pipe, which along with plug and cable that plugs into the hitch socket, and the cable is small enough to pass through the soft seal of the boot lid.