My PHP isn’t that great, so take this with a grain of salt: but I would think a simple elseif flow could work. I first thought of a switch, but not sure how each case would line up with each rating.
<?php
$rating = get_field('activity_rating);
if ($rating == 1):
$img_url = 'bloginfo("template_directory_uri()/img/1.jpg")';
elseif ($rating == 2):
$img_url = 'bloginfo("template_directory_uri()/img/2.jpg")';
.
.
.
endif;
?>
Or, rather than passing the entire image url to $img_url, you could just do: $img_url = "img/rating-1.jpg";
, but that depends on what your markup is like.