Probably yes but unless its a free of charge CPU from another computer, I would't really bother with the upgrade.
Like @goodplay said, you will need to look if its compatible.
My honest opinion, don't spend any money and save for something better. Even a 5600G will be leaps and bounds superior to that without even needing to add a GPU.