This paper investigates the physical layer security (PLS) design of an untrusted relaying network where the source node coexists with a multi-antenna eavesdropper (Eve). While the communication relies on untrustworthy relay nodes to increase reliability, we aim to protect the confidentiality of information against combined eavesdropping attacks performed by both untrusted relay nodes and Eve. Considering the hardware impairments (HIs), both total power budget constraint for the whole network and the individual power constraint at each node, this paper presents a novel approach to jointly optimize relay beamformer and transmit powers aiming at maximizing average secrecy rate (ASR). To safeguard the first cooperative phase, destination-aided cooperative jamming (DACJ) is employed, while for the second phase, the relay beamformer is adjusted. The resultant optimization problem is non-convex, and a suboptimal solution is obtained through the sequential parametric convex approximation (SPCA) method. In order to prevent any failure due to infeasibility, we propose an iterative initialization algorithm to find the feasible initial point of the original problem instead of an arbitrary point, as in the conventional SPCA. To satisfy low-latency as one of the main key performance indicators (KPI) required in beyond 5G (B5G) communications, a computationally efficient data-driven approach is developed exploiting a deep learning model to evaluate the proposed scheme while the computational burden is significantly reduced. Simulation results assess the effect of different system parameters on the ASR performance as well as the effectiveness of the proposed deep learning solution in large-scale cases.