Can you buy a prepaid phone in minnesota and have it work in california?

Depending on the network yes and no.

National carries (AT&T Verizon sprint and tmobile) generally yes.

Regional carries... Generally no.