You can first get a good understanding of 하기 and its usage.
하기 is the noun form of the verb 하다(do), what "doing" is to "do".
The noun form can also create a long phrase: 이렇게 어려운 일을 빨리 하기 (Doing such a difficult task quickly).
- 이 일은 빨리 하기 어렵다: It's difficult to do this task quickly.
We can think of it like Subject(이일은) + Predicate Sub-clause(빨리 하기 어렵다), and 하기 is the subject in the clause.
(A different grammatical interpretation is also possible)
That is, 하기(가) 어렵다 = Doing (it) + is difficult, where "doing (하기)" is the subject.
So 하기를 어렵다 is ungrammatical and never used because 를 is strictly an object marker - there's no exception.
Both 하기는 어렵다 and 하기가 어렵다 are good since 는 and 가 mark the subject (or topic) of the sentence.
하기 어렵다 is a form where the subject marker is elided, which happens often.
These threesome structures show up all over the language: 나는 햑생이야 / 내가 학생이야 / 나 학생이야.
It takes a good understanding and practice of the language to acquire a sense of the different nuances of these three.