It's assuredly possible to write it in SQL. Here's a starting point:
select array(
select substring(str from i for 1) as bit
from generate_series(1, length(str)) as i
where bit = '1'
);
You might want to wrap that in a pl/sql function regardless, though, so to avoid duplicating code all over the place.
Working function:
create or replace function get_bit_positions(varbit) returns bit[] as $$
select array(
select substring($1 from i for 1) as bit
from generate_series(1, length($1)) as i
where substring($1 from i for 1) = '1'
);
$$ language sql immutable;