Would a vitamin B12 deficiency affect my sleep?

Yes. If you have pernicious anemia with your vitamin B12 deficiency, you can have nervous system problems that can include incontinence and muscle spasms which can affect sleep. Treatment with intramuscular injections of vitamin B12 can help. If you have a mild deficiency but not pernicious anemia, it is less likely that sleep will be affected.
Yes . Lack of vitamin B12 can contribute to many alignments. Ranging from weakness, constipation and a loss of appetite. There are some links to depression and dementia. All these can affect your sleep. Fortunately only a small segment of the population less than 15% do not get enough in the food that we eat. Ask your doctor to test your level.