Edit: I assumed bread dough here, during initial kneading. Seeing Stephie's answer made me remember that "kneading" applies to many more contexts. But please keep my assumption in mind when reading the answer here.
Yes, you can knead it with a rolling pin if you want to. You'll have to repeatedly roll it into a flat shape, fold it once or a few times into a thicker shape, than roll again. This is similar to a stretch-and-fold hand kneading method, and will produce a very well aligned gluten structure with distinct gluten "layers".
But in practice, you will run into a few problems. First, some of the most interesting types of bread, where you worry the most about kneading quality, are made with a very high hydration dough, 80% and above. This dough will stick to a rolling pin terribly. You don't want to add flour until it stops sticking (this will ruin the dough), so you'll spend more time scraping dough off the rolling pin than kneading.
Second, the rolling pin is unwieldy. With a bit of exercise, it is easy to develop the correct kneading movements for kneading by hand and execute them efficiently. A rolling pin will slow a good kneader down. It will also prevent you from feeling the dough, making it harder to judge how much to knead.
Bottom line: Experienced bakers find their hands to be the most convenient instrument. If you for some reason find the rolling pin more convenient, use it.
See also Why stretch and fold vs traditional kneading of bread dough? and Does the direction matter in the Stretch and Fold method? for more info on what you are trying to emulate with the rolling pin.