This can be generalized so the procedure takes the size, random generator and whether to produce an upper or lower triangular matrix as arguments.
genUniModular := proc(size, {gen := rand(10), type := upper})
local i, U:=LinearAlgebra[RandomMatrix](size,size,generator=gen,shape=triangular[type]):
for i from 1 to size do U[i,i]:=1:end do:
return U:
end proc:
The only required argument is the size of the matrix, the others are optional.
Usage:
genUniModular(4, gen = rand(-10..10), type = lower)
to generate a 4x4 lower triangular unimodular matrix with non-diagonal elements between -10 and 10