Apparatus for esterification or etherification of cellulose