There are multiple ways makers navigate such process depending upon the role of the actor, the progress of shooting and the financial aspect of the making.
In case of a minor character, makers generally used a body double or long shots to shoot without anyone letting know that the actor has been changed. The great Satyajit Ray did in his iconic film Pather Panchali (1955) where one of the minor characters playing a shopkeeper passed away so the makers used a man with same height and measurements and shot the remaining sequence using over the shoulder shots of the new actor. Interestingly in the same film the dog used for a sequence passed away before the sequence could be finished so they had to find an identical dog for the sequence.
Body double was also used to shoot some minor song sequences in the film Rang (1993) after Divya Bharti passed Away.
In case a major character of the film pass away they have to be replaced by a new actor and a lot of reshooting is done. For example Divya Bharti had signed more than a dozen films including Laadla (1994), Mohra (1994), Kartavya (1995) etc. In such cases she was replaced by Sridevi, Raveena Tandon, Juhi Chawla etc in these movies.
In rare cases, the makers tweak the story of the film to justify the absence of the actor. In the film Professor ki padosan (1994), which got shelved due to the untimely demise of Sanjeev Kumar and was revived years later, the makers added a track where Sanjeev Kumar is shown drinking a magic potion which made him invisible for the rest of the film and used dubbing artists to dub his voice for the rest of the film. This obviously changed the whole narrative of the film and the film failed badly. In another film of Sanjeev Kumar Hirasat (1987), Sanjeev Kumar was replaced by Shatrughan Sinha but his song was not removed from the film. Instead they show Shatrughan Sinha watching a movie in the theatre and they show the same clips and songs which was originally picturised on Sanjeev Kumar!!
In rare cases the actors are changed in between the film and the same role is played by more than one actor. A few years ago, Sharmaji Namkeen (2021) had Rishi Kapoor in the lead role who shot for significant portions of the film but agter his demise the rest of the film was shot with Paresh Rawal. The makers promoted the film as a tribute to Rishi Kapoor and didn't reshoot the whole film.