In reply to rag123:
I would do something like what I show below. Tune it to your needs. The idea is to add local variables in your initial, randomize them, and then AND?OR them as needed.
initial begin : ini1
logic [31:0] v_wdata; // <---
bit [4:0] v_select; // bit to inject error on any of 32 bits
// A value of X on WDATA valid byte lane is not permitted when WVALID is high.
// inject the X on WDATA and test it out.
// Is there anyway through randomization i can inject X on any 8 bits?
repeat(100) begin :rpt1
repeat(1) @(posedge clk) #1;
if (!randomize(wvalid,wstrb, v_wdata, v_select) with
{wvalid dist {1'b1:=1,1'b0:=1};
{$onehot(v_select) };
// wstrb dist { 1'b1:=1,1'b0:=1};
// $onehot(wstrb);
}) `uvm_error("MYERR", "This is a randomize error");
v_wdata= wdata | (v_select & 'X); // vselect is onehot , making that onehot bit an X
//
for (int i=0;i<=3;i++) begin :for1
ss_sel <= wstrb >> i;
mod_data[8*i+:8] <= ss_sel ? v_wdata [8*i+:8] : 'h00; // <-----
end : for1
end : rpt1
$stop;
end : ini1