Use can in a question when you're asking about ability, permission, or possibility: Can you swim? The order is can + subject + base verb, with no do or does. For permission, can is the casual choice, so it fits people you know well.
Choosing the condition beside your sentence
Asking if someone is able to do something? That's an ability question. Can you sleep on your back? Here can comes first, then the person, then the base verb. If you asked Can this bridge hold the truck? instead, you'd be asking about a chance, not anyone's skill.
Need to ask for permission? Permission requests always take the form of a yes/no question. Can I take Daisy for a walk? The answer will be yes or no, not an explanation of someone's ability.
Wondering whether something might happen? That's a possibility question, not an ability one. Can this medicine cause drowsiness? You're asking about the chance it happens, not whether anyone can do it. Contrast Can you lift this box?, which is about someone's ability.
Same word order works across all three conditions. Can you swim? asks about ability, Can I leave early? asks for permission, Can we still get tickets tonight? asks about a possibility. The situation tells your listener what you mean; the grammar stays can plus subject plus base verb.
Asking a yes/no question with can
When you want a yes/no answer, put can first, then the subject, then the base verb. This one pattern covers all three things can can ask about. You might be checking a possibility: Can this bridge hold the truck? is about whether the bridge can bear the weight, not about anyone's driving skill. You might be asking permission: Can I take Daisy for a walk? is a yes/no request to the person in charge. And a question like Can this medicine cause drowsiness? asks whether something might happen, again with can in front of the subject. Whatever you mean, the grammar stays the same; the situation tells your listener which question you're really asking.
Asking for permission works the same way. Can I take Daisy for a walk? is you checking whether it's allowed, and Can we wear jeans at work? does the same in an office setting. Nobody is asking about anyone's skill here; you're simply asking the other person to say yes or no.
Possibility questions look identical in shape but mean something different. Can this medicine cause drowsiness? isn't about anyone's ability to do anything. You're asking whether something might happen. That same can plus subject plus base verb order carries across all three situations, so Can you swim? (ability), Can I leave early? (permission), and Can we still get tickets tonight? (possibility) all keep the same word order. The situation, not the grammar, tells your listener what you mean.