Some of these pictures and descriptions may give away plot details that you might not want to know before watching the film.
This is one of the few big budget Michael Bay action movies that wasn't a huge hit at the box office. It's sort of an update of Logan's Run, the 1976 Sci-Fi classic.
Ewan McGregor and Scarlett Johannson have just escaped from a giant corporate cloning complex hidden deep underground in an old military bunker in the Arizona desert some time in the near future. They were raised in what they were taught to believe is an underground utopia populated by survivors of a mass contamination event that killed almost all life on earth, which they find out is a lie once they escape.
The first living creature they see after they get outside is a rattlesnake. They don't know what it is, but the fact that it's alive is proof to them there is still life outside the complex. Like all movie rattlesnakes, this one rattles constantly and strikes, unlike most real rattlesnakes. Ewen McGregor's character repeats the myth that rattlesnakes are just plain mean and not simply defending themselves. But at least he and Scar Jo's character leave the snake alone and keep running instead of killing the snake like people do in most movies.
I'm going to guess that the movie uses a rattlesnake because the two are supposed to learn that there are other dangerous animals outside the complex besides the mercenaries in black helicopters who are hunting them. Or maybe they just used a rattlesnake to excite us because that's what big macho action movies are about. Nevertheless, I consider this one of the rare appearances of a rattlesnake or any other kind of snake in a movie that is shown in a fairly realistic way, because it isn't used here only to provide a convenient dramatic plot-change device like a snakebite or a heroic snake killing.
The snake used in the scene is a location-appropriate Western Diamond-backed Rattlesnake. I don't know how they filmed the encounter. Visual effects are so good now that they can make me belive anything, but it looks like the actors were actually in the frame with the snake, so they may have just used the old school technique of putting a pane of glass between them and the snake. It even looks like the snake hits the glass when it strikes, which backs up my theory.