Então, se seu js estiver inline, você consegue usar o php dentro da tag script, veja como:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<link rel="stylesheet" href="css/style.css">
<link rel="author" href="humans.txt">
</head>
<body>
<?php
$cod = 23;
?>
<select name="select" class="select2<?= $cod?>" id="item1">
<option value="01">01</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$('.selects2<?= $cod ?>').select2();
</script>
</body>
</html>
Agora, caso seu js estiver dentro de um arquivo externo, você pode criar uma variavel na window e recuperar ela no seu arquivo, assim:
HTML:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<link rel="stylesheet" href="css/style.css">
<link rel="author" href="humans.txt">
</head>
<body>
<?php
$cod = 23;
?>
<select name="select" class="select2<?= $cod?>" id="item1">
<option value="01">01</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
window.classeSelect = ".select2<?= $cod ?>";
</script>
<script src="script.js"></script>
</body>
</html>
JS:
$(window.classeSelect).select2();