When making a call to the constructor the class is parameterized with byte but for handle p2 data type is int. As both are of different data types you are getting an error.Do the changes as shown below.
class packet #(type T=int);
T b;
int a=5;
endclass
module abc;
packet#(byte) p2, p1;
initial begin
p2 = packet#(byte)::new() ;
//while doing shallow copy not to use typed constructor as in below line
//p1 = packet#(byte)::new p2; error not possible as per LRM
p1 = new p2;// correct way to copy
end
endmodule