Sure, you can use attention mechanism for the seq-2-one.
You can just imagine the seq-2-one is a special case in seq-2-seq. Attention mechanism just adjust the weights to the input features of decoder by the features, last output and last hidden of RNN (not necessary if decoder is not a RNN). This mechanism itself even don’t know you are doing seq-2-one or seq-2-seq task. It’s all up to you.
Did you see these examples? You can see them as the introductory tutorial.

  
      
      GitHub
  
  
    

AuCson/PyTorch-Batch-Attention-Seq2seq 678

PyTorch implementation of batched bi-RNN encoder and attention-decoder. - AuCson/PyTorch-Batch-Attention-Seq2seq


  
  
    
    
  
  



  
      
      GitHub
  
  
    

spro/practical-pytorch 445

PyTorch tutorials demonstrating modern techniques with readable code - spro/practical-pytorch


  
  
    
    
  
  



  
      
      GitHub
  
  
    

keon/seq2seq 276

Minimal Seq2Seq model with Attention for Neural Machine Translation in PyTorch - keon/seq2seq