Create range from column
If the first range is allowed to start with 0, you can do something like this:

with ranges (range) as (
  select int4range(i, i + 1000, '[)')
  from generate_series(0, (select max(pos) from varianti), 1000) as i
) 
select range,
       count(v.pos) as range_count
from ranges l
  left join varianti v 
         on v.pos &lt;@ l.range
group by range
order by range;


For this data:

insert into varianti (pos)
values
(123), (150), (170), 
(1025), (1050), (1051), (1052), (1053), (1054), (1054), 
(2054), (2051), 
(3001), (3002), (3003), (3004), (4004), 
(5426);


This returns:

range       | range_count
------------+------------
[0,1000)    |           3
[1000,2000) |           7
[2000,3000) |           2
[3000,4000) |           4
[4000,5000) |           1
[5000,6000) |           1