1D signal to 2D spectrogram
If you're working in the MATLAB environment, the STFT of a 1D signal can be obtained by using the Spectrogram() command. Refer here

And as for PSD, you can use the FFT to obtain the same. Refer here