Yes, you can. However, they are going to have a better texture freshly made. I would recommend using the frozen and thawed mushrooms and onions in casserole dishes or as an ingredient in soup. To freeze the leftovers, make sure they are cold, then package them in a freezer container or vacuumed sealed bag and make sure to include the juices to help prevent freezer burn.