dependent variable One hot encoder
OneHotEncoder will create k number of columns if there are k classes for a single variable.
For example : it will create 2 variables if  gender values in that dataset are Male/Female,
It will create 3 Variables if gender values are male/Female/PreferNotToSay
Now, You don't want multiple variables in your predicate y, So better go with LabelEncoder(from sklearn.preprocessing) or some mechanism that keeps the dimensionality intact.
I am new to machine learning my question is: 

Do we need to encode dependent variable y if it contains three class
  segments 1,2,3 and I want to know if there is need to encode the
  dependent variable when it contains no