Pseudo-Hermiticity for a class of nondiagonalizable Hamiltonians