For the MNIST dataset, you could try to either manipulate the underlying data and target attributes or write a custom Dataset using the MNIST dataset as the parent class and implement your sampling logic e.g. in the forward method by passing a specific class flag.
I would prefer the latter case, as it sounds cleaner.
To add a new neuron to the last layer, I would recommend to use the functional API, store the parameters e.g. in a nn.ParameterList, and add the new parameter to this list.
Alternatively, you could also manipulate the last linear’s parameters also by reassigning the new weight parameter and copy the old values in.
I’m not sure how you would like to deal with the optimizer. Would you like to reinitialize it after each change in the model?