The following is a way of estimating the solution in discrete-time domain. This requires a couple of changes to your code:
Increase the sample rate Fs to preserve more bandwidth. I used 100x below.
Replace Dirac delta function by Kronecker delta to enable discrete-time modeling.
The modified code and the results are as follows:
Fs=100; % use higher sampling rate
t=-10:1/Fs:10;
d=(abs(t)-1)==0; % use kronecker delta function for discrete-time simulation
s=sign(t);
x=d.*s;
x2=1*(t>-1 & t<2);
spl=conv(x,x2,'same');
% plots to visualize the results
figure;
subplot(3,1,1);
plot(t, x2);
ylabel('f(x)');
subplot(3,1,2);
plot(t, x);
ylabel('g(x)');
subplot(3,1,3);
plot(t, spl);
xlabel('Time');
ylabel('convolution');

convfunction,convis for discrete numerical convolution. If you want to verify your integration, rewrite the convolution as an integral and use the functionintfor symbolic integration.