Yes, you can, but bear in mind shallots are sweeter as well as stronger in taste, so you might want to use a smaller amount.