The main question is why do you have to do it? The JSON structure is unnecessarily complex and illogical. You should keep JSON data as simple as possible. You can store the same data in a single object:
{"test1key": "test1Value", "test2key": "test2Value", "test3key": "test3Value"}
and then the update is as simple as
update my_table
set json_col = json_col || '{"test1key": "newValue1", "test2key": "newValue2"}'
where id = 1
Even if the data comes from outside, you can always convert it to a simpler and more efficient form before saving to the database. Too complex data structure makes its processing (especially updates) difficult and inefficient:
update my_table t1
set json_col = new_array
from (
select id, jsonb_agg(jsonb_build_object(old_key, coalesce(new_value, old_value))) as new_array
from my_table
cross join jsonb_array_elements(json_col) as a(elem)
cross join jsonb_each_text(elem) as e(old_key, old_value)
left join jsonb_each_text(
'{"test1key": "newValue1", "test2key": "newValue2"}'
) as v(new_key, new_value)
on old_key = new_key
group by id
) t2
where t1.id = 1 and t2.id = t1.id;
Online demo: db<>fiddle.