I'm not sure if I fully understand your logic, but I think this can be done with a recursive CTE:
I added another case group to demonstrate, that this approach can deal with different groups in one go.
declare @tdac table(secnum varchar(100),bucketcode varchar(100),caseid int,acc varchar(100),defqty int);
insert @tdac(secnum,bucketcode,caseid,acc,defqty)
values('ax1','cor',1,'012',-100)
,('ax1','cor',2,'012',-50)
,('ax1','cor',3,'012',-150)
,('ax2','cor',1,'012',-100)
,('ax2','cor',2,'012',-100);
declare @dac table(secnum varchar(100),bucketcode varchar(100),caseid int,acc varchar(100),defqty int);
insert @dac(secnum,bucketcode,caseid,acc,defqty)
values('ax1','cor',0,'012',-125)
,('ax2','cor',0,'012',-150);
--the first CTE will find all distinct groups and add the value of @dac as start value to the set
WITH DistinctGroups AS
(
SELECT t.secnum,t.bucketcode,t.acc,d.defqty
FROM @tdac AS t
LEFT JOIN @dac AS d ON d.secnum=t.secnum and d.bucketcode=t.bucketcode AND d.acc=t.acc
GROUP BY t.secnum,t.bucketcode,t.acc,d.defqty
)
-the recursive CTE
,recursiveCTE AS
(
--anchor: Get the rows with the minimal caseid from each group
SELECT t.secnum,t.bucketcode,t.caseid,t.acc,t.defqty,CASE WHEN x.NewQty>0 THEN 0 ELSE x.NewQty END AS NewQty,CASE WHEN x.NewQty>0 THEN x.NewQty ELSE 0 END AS NewDiff
FROM @tdac AS t
INNER JOIN DistinctGroups AS gr ON t.secnum=gr.secnum AND t.bucketcode=gr.bucketcode AND t.acc=gr.acc
CROSS APPLY(SELECT t.defqty-gr.defqty AS NewQty) AS x
WHERE t.caseid=(SELECT MIN(caseid) FROM @tdac AS t2 WHERE t2.secnum=gr.secnum AND t2.bucketcode=gr.bucketcode AND t2.acc=gr.acc)
UNION ALL
--find the row with the next caseid and add the diff value of the previous row
SELECT t.secnum,t.bucketcode,t.caseid,t.acc,t.defqty,CASE WHEN x.NewQty>0 THEN 0 ELSE x.NewQty END AS NewQty,CASE WHEN x.NewQty>0 THEN x.NewQty ELSE 0 END AS NewDiff
FROM @tdac AS t
INNER JOIN recursiveCTE AS r ON t.secnum=r.secnum AND t.bucketcode=r.bucketcode AND t.acc=r.acc
CROSS APPLY(SELECT t.defqty+r.NewDiff AS NewQty) AS x
WHERE t.caseid=r.caseid+1
)
select *
from recursiveCTE
order by secnum,caseid
The result
ax1 cor 1 012 -100 0 25
ax1 cor 2 012 -50 -25 0
ax1 cor 3 012 -150 -150 0
ax2 cor 1 012 -100 0 50
ax2 cor 2 012 -100 -50 0