The short answer is yes. But modern vehicles are “computers on wheels” so you must follow proper installation procedures to avoid damaging the ECM (Engine Control Module) and TCM (Transmission Control Module).
Plus, if the battery gets incorrectly installed, items like the radio, the navigation system and security codes may need to be professionally reset. In cars fitted with air bags, extra care needs to be taken to ensure that no unintentional damage is done to the electrical system that can impact of the air bag system operates.
Never try and replace a battery with the ignition or other items like the radio or lights on. Keys should be removed from the ignition and if you have a car with keyless start, you should keep the fob at least 2 metres from the car.