Graphic designers work with all types of media. Their designs are printed on paper, silk screened onto signage, and displayed on screens as an app or website, to name just a few. Understanding what is and isn't possible in the intended medium is crucial to creating an effective design.
So, yes, designing for digital media like websites and apps requires understanding what you can and can't do with code. Knowing how to code a website on your own isn't necessary, just understanding the high level concepts and being able to have a conversation with developers is enough.
You can sketch almost anything, and while that freedom can be an important part of the creative process, a designer knows that for any project, success depends on well defined constraints. Learning about the limitations of your medium is an essential part of being a designer, but you don't need to “write the code” yourself.