How do I print a dynamic array in the convert2string method of transaction class?

If you want your entire array on a single line, you can write

function string convert2string();
  string str1;
  str1 = {
       $sformatf("m_first :'h%h\n", first),
       ....
         }
  $swriteh(str, "%s wdata :%0p\n", str, wdata),
  return(str1);
endfunction

Otherwise you will need to use a foreach or for loop to iterate over each element and insert newlines where you want them.