You specify it as a parameter: $Pos(0) - this just tells the iterator to start its numbers at 0 instead of 1.
The $Pos will be available anywhere inside the loop, and will return the current position in the loop, you don’t need to define it.
<% loop $feature %>
<button data-bs-slide-to="$Pos(0)"></button>
<% end_loop %>
Would result in:
<button data-bs-slide-to="0"></button>
<button data-bs-slide-to="1"></button>
<button data-bs-slide-to="2"></button>
<button data-bs-slide-to="3"></button>