Actors (especially big names) can and do improvise all the time, in almost all movies.
It's rare they say all lines exactly as in the script. In fact often the script gets updated with ideas that came up during shooting including improvised lines.
A fascinating topic around my family is the playwrights who insist that the play be delivered precisely as written, most of whom are the same playwrights who refuse to allow genderswapping roles (even innocuously), updating pop culture references, etc. They are not the norm, and pretty much everyone understands that performance is as much a part of the creative act as writing, with all the deviations and imperfections that suggests. And that's without even getting to the idea of consciously changing the script midstream that you mentioned.
That's why in almost all cases screenwriters or source novel writers are strictly forbidden on set.
The biggest problem are writer/directors who cannot deal with improvising actors. Like a Haneke, who would turn around in his grave if an actor goes against his sacred script. That's why they have 25 shots per scene, and 3-6 months per shoot.
Just because you hear that they do, doesn't mean it's always allowed or that it will make it into the film.
Sometimes a line just isn't working and an actor or the director or the writer or a grip will come up with something that works and that's what you hear about. Those are exceptions and not the rule.
The director has the final say. Often others higher up have the final say. If he wants you to say the line as written, you will say the line as written.
I didn't say it's "always allowed". There are difficult directors with very specific vision they want to express 100%. It's that that is the exception and not the rule, however.
In general it's more common that some lines will change and be improvised by the actors, than not.
It's even practical, some lines come off as stiff when the actors tell them verbatim, others just can't be replicated in a longer emotionally charged scene (where the flow and the emotions carry the performance), and so on.
>Often others higher up have the final say. If he wants you to say the line as written, you will say the line as written.
Harrison Ford says, "I know," instead of "I love you, too" (or something like that) in Empire Strikes Back's carbonite freezing scene. That's an immensely significant and meaningful update.
It's rare they say all lines exactly as in the script. In fact often the script gets updated with ideas that came up during shooting including improvised lines.