The issue is that JSON_VALUE returns an NVARCHAR and you sent in an INTEGER. This causes a Convert_Implicit.
If you pass in a VARCHAR or NVARCHAR param/value into the WHERE condition, it does a seek and drops the rows read.
Use conditional aggregation to get the sums depending on is_tag_stock and jsonb_build_object() (or json_build_object()) to create the encapsulating JSON.
WHEN is_tag_stock THEN
Be aware that order of array items is a different issue than order of keys in JSON object. See:
How to sort objects in an array inside a json or jsonb value by a property of the objects?
For your first example (implying integer sort), simply casting to jsonb would do the job. It happens to sort keys the way you want by default:
SELECT jsonitem::jsonb FROM ...