My specialised subject.
Short answer - it depends.
@Dr Hoo brilliantly summarises the principles.
I will leave aside the cost of the physical work and planning thereof.
The cost of the act of taking the possession -PICOP, “block road men”, isolation staff if required, is simply the cost of staff, vans, fuel and some kit. If you have to hire the people in (as opposed to using full time staff as part of their normal duties) it will be somewhere between £2k and £20k depending on the complexity and duration of a possession. The cheaper end is for a simple 2 line non electric railway overnight block, the top end for a complex electric railway with junctions aplenty for a weekend. Obviously long blockades are more expensive, albeit the big cost is the taking and handing back.
The compensation to train operators is very complex. Essentially, compensation is paid for any service that is timetabled to run in the base timetable (the ‘applicable day’) but is subsequently diverted, shortened in journey length, or cancelled altogether. (Calculations done on something called monitoring points, which is some, but not all, stations each train is due to serve). Each service is part of a ‘Service Group’, which has rates applicable for the train. These rates vary considerably by service group, depdnign on how valuable they are, and most groups have a peak and off peak rate, and are intended to represent the value of the average service in that service group. Discounts are applied for advance notice - very advance that is. The most valuable service group always use to be Thameslink Bedford to Blackfriars, with LNER to Yorkshire close behind. I suspect this may have changed.
A weekend block of a rural branch line might cost a couple of hundred pounds. A full week of Waterloo will be in the millions.
Perhaps the best news is that the process for working all this compensation out is largely automatic, and requires relatively little staff time.
The bad news is that for works that are not classified as maintenance or steady state renewals, operators are entitled to claim their full costs and losses, and that is a negaotiated settlement which naturally takes more time.