Job name / JobID are created once the job is accepted.
We cannot variable substitute JobNames and JobID within the PBS attributes.
cat pbs.sh ; chmod +x pbs.sh ; qsub pbs.sh
#!/bin/bash
#PBS -N test
#PBS -l select=1:ncpus=1:mem=1gb
/bin/hostname >> $PBS_JOBNAME.$PBS_JOBID.out 2>&1