To modify markup values using JavaScript you have to execute JavaScript code in the client browser. (The HTML text has already been generated on the server.)
The code could be something like:
<ul class="dropdown-menu">
</ul>
<script>
var idForDropDown = someValue;
document.getElementsByClassName('dropdown-menu')[0].id = idForDropDown;
</script>
See documentation such as getElementsByClassName. Fairly unusual to be setting an id like that though.
If the id value can be worked out when the page is generated on the server (before it is passed to the client browser) and you were using Visualforce this would work because the id value is merged into the HTML text:
<ul class="dropdown-menu" id="{! idForDropDown }">