The technology of reconfigurable intelligent surfaces (RIS) has been showing promising potential in a variety of applications relying on Beyond-5G networks. Reconfigurable intelligent surface (RIS) can indeed provide fine channel flexibility to improve communication quality of service (QoS) or restore localization capabilities in challenging operating conditions, while conventional approaches fail (e.g., due to insufficient infrastructure, severe radio obstructions). In this paper, we tackle a general low-complexity approach for optimizing the precoders that control such reflective surfaces under hardware constraints. More specifically, it allows the approximation of any desired beam pattern using a pre-characterized look-up table of feasible complex reflection coefficients for each RIS element. The proposed method is first evaluated in terms of beam fidelity for several examples of RIS hardware prototypes. Then, by means of a theoretical bounds analysis, we examine the impact of RIS beams approximation on the performance of near-field downlink positioning in non-line-of-sight conditions, while considering several RIS phase profiles (incl. directional, random and localization-optimal designs). Simulation results in a canonical scenario illustrate how the introduced RIS profile optimization scheme can reliably produce the desired RIS beams under realistic hardware limitations. They also highlight its sensitivity to both the underlying hardware characteristics and the required beam kinds in relation to the specificity of RIS-aided localization applications.