While this should be doable, the way you’ve described is the most complicated to implement. The input is a string which requires parsing, and the 2nd half of HOST_PORTS is redundant because there has to be a 1:1 mapping, so you’re just doing extra work to parse and then throw it away.
The most straightforward way would be 3 variables: container_start=8000, container_count=6, and host_offset=500. You should be able to use those, range, until, and add to do what you want.
To do container_end instead of container_count or host_start instead of host_offset you need a little more math. There is actually also string splitting in sprig, so if you really want you can even use exactly the 2 variables you said.