One of the first requirements of patentability is the utility requirement of 35 USC 101: “Whoever invents or discovers any new and useful process, machine, manufacture, or composition of matter, or any new and useful improvement thereof, may obtain a patent therefor, subject to the conditions and requirements of this title.” Since something that doesn’t work is not useful, the short (and correct) answer is no, you cannot patent something that does not work.
While the USPTO is not supposed to issue patents on technology that doesn’t work, the Office is not always able to identify non-functioning technology. To be sure, if the disclosure is implausible, an Examiner would reject the application for failure to comply with the enablement requirement of 35 USC 112 (a): “The specification shall contain a written description of the invention, and of the manner and process of making and using it, in such full, clear, concise, and exact terms as to enable any person skilled in the art to which it pertains . . . to make and use the same.” Moreover, if the Examiner is suspicious, then Examiner can require the applicant to provide a working model: “The Director may require the applicant to furnish a model of convenient size to exhibit advantageously the several parts of his invention.” 35 U.S.C. 114.
Where the applicant tips off the Examiner, for example with an crazy title or a deficient disclosure, the USPTO will likely reject the application.
However, not all applicants are accommodating enough to flag their disclosures as inoperative. Thus patents do issue that might not have with greater scrutiny. For example, U.S. Patent No. 6,362,718 on a Motionless Electromagnetic Generator, purportedly covers “a magnetic generator used to produce electrical power without moving parts, and, more particularly, to such a device having a capability, when operating, of producing electrical power without an external application of input power.” Interestingly, there is a U.S. patent classification (415/916) for perpetual motion, and ever more interestingly, in addition to 239 published applications, there are 27 issued patents in the class!
A better question than “can you patent inoperative technology” would be: “why would you want to?” No one can infringe a patent on technology that does not work, but enforcement is not always the ultimate goal for a patent. An issued patent is a sort of endorsement of the disclosed technology, and that endorsement alone may be sufficient reason to pursue a patent. However the issued patent is only an endorsement that the disclosure is novel and non-obvious, and not an endorsement of the technology per se.