If anyone uses Unreal 5.3 for this course, the SpawnSoundAtLocation signature seems to have changed.
I made it work like this:
const FVector Location = Mesh->GetSocketLocation(TEXT("MuzzleFlashSocket"));
const FRotator Rotation = Mesh->GetSocketRotation(TEXT("MuzzleFlashSocket"));
UGameplayStatics::SpawnSoundAtLocation(
GetWorld(),
MuzzleSound,
Location,
Rotation
);