Generally speaking, there is no unique boolean function $f(p, q)$ that produces your output. For your example, the function $f(p, q) = p$ would be a valid solution, as well as $f(p, q) = (p \vee q) \wedge (p \vee \neg q)$, and $f(p, q) = (p \wedge q) \vee (p \wedge \neg q)$.
You can find an equisatisfiable function to the one that produced the given output, and there are a number of approaches to do so.
A simple approach would be the enumeration of variable constellations that produce $\top$, and disjunct them. For your example that would mean first finding the constellations that produce $\top$:
- $p \wedge \neg q$
- $p \wedge q$
and finally producing $f(p, q) = (p \wedge q) \vee (p \wedge \neg q)$
This way you produce a function in disjunctive normal form (DNF). A similar approach works for CNF, but in both cases you end up with a fairly large function.
More complex approaches are Karnaugh Maps and the Quine McCluskey algorithm. They can produce much more concise, even minimal equisatisfiable functions.
As far as I know, most approaches focus on CNF (and sometimes DNF), i.e. use only conjunctions, disjunctions and negations, and don't nest operators any further.