Can I write my thesis at a company?

That highly depends upon which company (and department) you’re talking about. For most multinational firms, such as Big-4 companies, it is quite common that students can do a graduate internship. Your thesis supervisor is responsible for the thesis and content itself, but a mentor in the company will also guide you to the process and introduce you to working I that specific department.